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

 
(사용자 2명의 중간 판 11개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
;Pyplot 산점도
{{소문자}}
;파이썬 산점도
;pyplot 산점도


==예시 1: iris==
==예시 1: iris==
<source 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 )


13번째 줄: 15번째 줄:
plt.ylabel('Sepal width')
plt.ylabel('Sepal width')
plt.show()
plt.show()
</source>
</syntaxhighlight>


==예시 2: iris 색상==
==예시 2: iris 색상==
<source 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()
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
* [[산점도]]
* [[산점도]]
* [[R 산점도]]


[[분류: Pyplot]]
[[분류: Pyplot]]
[[분류: 산점도]]

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