pyplot
설정하기
jupyter notebook에서 사용
1 2 |
%matplotlib inline |
폰트 설정하기
동적으로 설정하기
1 2 3 4 |
from matplotlib import font_manager, rc font_name = font_manager.FontProperties(fname="c:/Windows/Fonts/malgun.ttf").get_name() rc('font', family=font_name) |
1 2 3 4 5 6 7 8 9 10 11 |
from matplotlib import font_manager, rc import numpy as np import matplotlib.pyplot as plt font_name = font_manager.FontProperties(fname="c:/Windows/Fonts/HANBatang.ttf").get_name() rc('font', family=font_name) plt.title("한글 ") x = np.arange(-0.5, 1, 0.01) plt.plot(x,x ** 2,"r--",) plt.show() |
위와 같이 설정할 경우 눈금에 표시되는 마이너스 문자가 깨지게 된다. 따라서 한가지 옵션이 더 필요하다.
1 2 3 |
rc('font', family='AppleGothic') plt.rcParams['axes.unicode_minus'] = False |
- backend 확인하기
123import matplotlibmatplotlib.get_backend() - 설정 확인하기
123import matplotlibmatplotlib.rcParams
샘플
- SCATTER 샘플 : https://matplotlib.org/examples/lines_bars_and_markers/scatter_with_legend.html#lines-bars-and-markers-scatter-with-legend
- scatter : https://matplotlib.org/examples/pylab_examples/scatter_custom_symbol.html
- scatter2 : https://matplotlib.org/examples/pylab_examples/scatter_demo2.html
- scatter + hist : https://matplotlib.org/examples/pylab_examples/scatter_hist.html
- scatter3 : https://matplotlib.org/examples/pylab_examples/shared_axis_across_figures.html
- histogram 샘플 : https://matplotlib.org/examples/pylab_examples/histogram_percent_demo.html
- histogram2 : https://matplotlib.org/examples/statistics/histogram_demo_features.html
- histogram3 : https://matplotlib.org/examples/statistics/histogram_demo_histtypes.html
- histogram4 :https://matplotlib.org/examples/statistics/histogram_demo_multihist.html
- 버튼 이벤트 : https://matplotlib.org/examples/widgets/buttons.html
- 체크버튼 이벤트 : https://matplotlib.org/examples/widgets/check_buttons.html
- 마우스 포인터 : https://matplotlib.org/examples/widgets/cursor.html
- 라쏘 셀렉터 : https://matplotlib.org/examples/widgets/lasso_selector_demo.html
- 메뉴 : https://matplotlib.org/examples/widgets/menu.html
- 라디오 버튼 이벤트 : https://matplotlib.org/examples/widgets/radio_buttons.html
- 슬라이드 셀렉터 : https://matplotlib.org/examples/widgets/slider_demo.html
- 데모목록 : https://matplotlib.org/gallery.html