"Pyplot 산점도"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(같은 사용자의 중간 판 6개는 보이지 않습니다)
7번째 줄: 7번째 줄:
<syntaxhighlight lang='python' run>
<syntaxhighlight lang='python' run>
import pandas as pd
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/jmnote/z-dataset/master/common/iris.csv')
df = pd.read_csv('https://raw.githubusercontent.com/jmnote/ds/main/R/iris.csv')
print( df )
print( df )


20번째 줄: 20번째 줄:
<syntaxhighlight lang='python' run>
<syntaxhighlight lang='python' run>
import pandas as pd
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/jmnote/z-dataset/master/common/iris.csv')
df = pd.read_csv('https://raw.githubusercontent.com/jmnote/ds/main/R/iris.csv')


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


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

2024년 1월 3일 (수) 11:42 기준 최신판

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 }}