티스토리 뷰
반응형
[데이터시각화] Matplotlib - Ticks 적용하기
Ticks
xticks
Get or set the x-limits of the current tick locations and labels.
yticks
Get or set the y-limits of the current tick locations and labels.
plt.yticks([0,1,2], ["one","two","three"])
전체코드
# Scatter plot
plt.scatter(gdp_cap, life_exp)
# Previous customizations
plt.xscale('log')
plt.xlabel('GDP per Capita [in USD]')
plt.ylabel('Life Expectancy [in years]')
plt.title('World Development in 2007')
# Definition of tick_val and tick_lab
tick_val = [1000,10000,100000]
tick_lab = ['1k','10k','100k']
# Adapt the ticks on the x-axis
plt.xticks(tick_val,tick_lab)
# After customizing, display the plot
plt.show()
Size
# Update: set s argument to np_pop
plt.scatter(gdp_cap, life_exp, s = np_pop)
Colors
# Specify c and alpha inside plt.scatter()
plt.scatter(x = gdp_cap, y = life_exp, s = np.array(pop) * 2, c=col, alpha=0.8)
# Previous customizations
plt.xscale('log')
plt.xlabel('GDP per Capita [in USD]')
plt.ylabel('Life Expectancy [in years]')
plt.title('World Development in 2007')
plt.xticks([1000,10000,100000], ['1k','10k','100k'])
# Show the plot
plt.show()
Additional Customization
# Scatter plot
plt.scatter(x = gdp_cap, y = life_exp, s = np.array(pop) * 2, c = col, alpha = 0.8)
# Previous customizations
plt.xscale('log')
plt.xlabel('GDP per Capita [in USD]')
plt.ylabel('Life Expectancy [in years]')
plt.title('World Development in 2007')
plt.xticks([1000,10000,100000], ['1k','10k','100k'])
# Additional customizations
plt.text(1550, 71, 'India')
plt.text(5700, 80, 'China')
# Add grid() call
plt.grid(True)
# Show the plot
plt.show()
반응형
'Data & MarTech > Data Analysis' 카테고리의 다른 글
[Pandas] CSV 파일 합치기 및 정제하기 (0) | 2023.07.10 |
---|
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- GTM
- bigquery
- GA API
- 구글애널리틱스4
- 구글시트API
- GCP
- 마테크
- 업무자동화
- googletagmanager
- 구글애널리틱스
- AWS
- googleanalytics
- 구글클라우드
- GA4 강의
- 파이썬
- GA4
- 오블완
- 구글태그매니저
- Google Tag Manager
- google sheet
- ChatGPT
- Google Analytics
- Martech
- google sheet api
- 빅쿼리
- 데이터전처리
- Ga
- IOS
- Python
- 데이터분석
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함