pyplot 산점도

1 개요[ | ]

파이썬 산점도
pyplot 산점도

2 예시 1: iris[ | ]

import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/jmnote/ds/main/R/iris.csv')
print( df )

import matplotlib.pyplot as plt
plt.scatter(df['sepal_length'], df['sepal_width'])
plt.xlabel('Sepal length')
plt.ylabel('Sepal width')
plt.show()

3 예시 2: iris 색상[ | ]

import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/jmnote/ds/main/R/iris.csv')

x = df['Sepal.Length']
y = df['Sepal.Width']
colors = df['Species'].astype("category").cat.codes

import matplotlib.pyplot as plt
plt.scatter(x, y, c=colors)
plt.xlabel('sepal length')
plt.ylabel('sepal width')
plt.show()

4 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}