티스토리 뷰
문제 1
- np.random.noraml() 함수를 사용하여 평균이 x축은 평균이 5, 표준편차가 3 이고, y축은 평균이 3, 표준편차가 2 인 샘플을 1000개 만들어서 이를 산점도로 표시하시오.
- 위의 산점도에서 축의 비율을 일정하게 놓으시오. (x축과 y축의 눈금길이가 일정하도록 한다. plt.axis() 함수 사용)
문제 2
- 임의의 그래프를 하나 그린 다음, 제목, x축 이름, y축 이름, 범례에 한글로 된 글자를 넣으시오.
정답
In [2]:
import numpy as np
import matplotlib.pyplot as plt
X = np.random.normal(5,3,1000)
y = np.random.normal(3,2,1000)
plt.scatter(X, y ,alpha=0.3)
plt.axis('equal')
Out[2]:
In [3]:
from sklearn.datasets import load_iris
iris = load_iris()
plt.figure(figsize=[12,10])
plt.scatter(iris.data[:,0], iris.data[:,2],c=iris.target, s=iris.data[:,1]*50 ,alpha=0.3)
import matplotlib.font_manager as fm
prop=fm.FontProperties(fname='C:/Windows/Fonts/gulim.ttc')
plt.title('꽃받침과 꽃잎 길이의 산점도', fontproperties=prop, fontsize=15)
plt.xlabel('꽃받침 길이 (cm)', fontproperties=prop)
plt.ylabel('꽃잎 길이 (cm)', fontproperties=prop)
plt.legend(['종류'], prop=prop)
Out[3]:
'beginner > 파이썬 퀴즈' 카테고리의 다른 글
파이썬 기초 퀴즈_9 (0) | 2019.03.09 |
---|---|
파이썬 기초 퀴즈_8 (0) | 2019.03.08 |
파이썬 기초 퀴즈_6 (0) | 2019.03.06 |
파이썬 기초 퀴즈_5 (0) | 2019.03.05 |
파이썬 기초 퀴즈_4 (0) | 2019.03.04 |