Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 데이터 분석
- 실습
- level 2
- level 1
- Numpy
- python3
- 알고리즘
- 파이썬
- R
- 튜닝
- 프로그래머스
- seaborn
- oracle
- Kaggle
- 빅데이터 분석 기사
- SQL
- Python
- matplotlib
- 머신러닝
- 오라클
- 카카오
- sklearn
- Oracel
- pandas
- 빅분기
- 실기
- 코딩테스트
Archives
- Today
- Total
라일락 꽃이 피는 날
[Matplotlib] 다양한 그래프 그리기 2 본문
728x90
6. Pie Chart
explode: 파이에서 툭 튀어져 나온 비율
autopct: 퍼센트 자동으로 표기
shadow: 그림자 표시
startangle: 파이를 그리기 시작할 각도
texts, autotexts 인자를 활용하여 텍스트 스타일링을 적용
texts는 label에 대한 텍스트 효과, autotexts는 파이 위에 그려지는 텍스트 효과를 다룬다.
labels = ['Samsung', 'Huawei', 'Apple', 'Xiaomi', 'Oppo', 'Etc']
sizes = [20.4, 15.8, 10.5, 9, 7.6, 36.7]
explode = (0.3, 0, 0, 0, 0, 0)
7. Box Plot
spread = np.random.rand(50) * 100
center = np.ones(25) * 50
flier_high = np.random.rand(10) * 100 + 100
flier_low = np.random.rand(10) * 100 - 100
data = np.concatenate((spread, center, flier_high, flier_low))
다중 박스플롯 생성
다중 그래프 생성을 위해서는 data 자체가 2차원으로 구성되어 있어야 한다.
data = np.concatenate((spread, center, flier_high, flier_low))
d2 = np.concatenate((spread, center*0.8, flier_high, flier_low))
data.shape = (-1, 1)
d2.shape = (-1, 1)
data = [data, d2, d2[::2,0]]
Box Plot 축 바꾸기
vert=False 옵션을 통해 표시하고자 하는 축을 바꿀 수 있다.
Outlier 마커 심볼과 컬러 변경
8. 3D 그래프 그리기
from mpl_toolkits import mplot3d
3d plot 그리기
x = np.sin(z)
y = np.cos(z)
z = np.linspace(0, 15, 1000)
sample_size = 100
x = np.cumsum(np.random.normal(0, 1, sample_size))
y = np.cumsum(np.random.normal(0, 1, sample_size))
z = np.cumsum(np.random.normal(0, 1, sample_size))
3d-scatter 그리기
sample_size = 500
x = np.cumsum(np.random.normal(0, 5, sample_size))
y = np.cumsum(np.random.normal(0, 5, sample_size))
z = np.cumsum(np.random.normal(0, 5, sample_size))
contour3D 그리기 (등고선)
x = np.linspace(-6, 6, 30)
y = np.linspace(-6, 6, 30)
x, y = np.meshgrid(x, y)
z = np.sin(np.sqrt(x**2 + y**2))
9. imshow
이미지 데이터와 유사하게 행과 열을 가진 2차원의 데이터를 시각화할 때 활용한다.
load_digits는 0~16 값을 가지는 array로 이루어져 있다.
1개의 array는 8 X 8 배열 안에 표현되어 있고, 숫자는 0~9로 이루어져 있다.
from sklearn.datasets import load_digits
digits = load_digits()
X = digits.images[:10]
X[0]
728x90
'데이터 분석 > Python' 카테고리의 다른 글
[Seaborn] 그래프 그리기 1 (0) | 2021.05.11 |
---|---|
[Seaborn] matplotlib 그래프를 seaborn으로 그리기 (0) | 2021.05.11 |
[Matplotlib] 다양한 그래프 그리기 1 (0) | 2021.05.11 |
[Matplotlib] 스타일 설정 (0) | 2021.05.08 |
[Matplotlib] 기본 그래프 그리기 (0) | 2021.05.08 |