データ分析と可視化
14437 ワード
Matplotlib
:さまざまな形式のグラフィックで、
1.図形の基本
1-1. Title設定
1-2. ハングルフォントの設定
2.軸
3.例
:さまざまな形式のグラフィックで、
1.図形の基本
import matplotlib.pyplot as plt
x = [1,2,3]
y = [2,4,8]
plt.plot(x,y)
plt.show()

1-1. Title設定
plt.plot(x, y)
plt.title('Line Graph')

plt.plot(x, y)
plt.title('꺽은선 그래프') #에러

1-2. ハングルフォントの設定
import matplotlib
matplotlib.rcParams['font.family'] = 'Malgun Gothic' #windows
matplotlib.rcParams['font.size'] = 10
matplotlib.rcParams['axes.unicode_minus'] = False
# 글씨체 확인하는 방법
import matplotlib.font_manager as fm
fm.fontManager.ttflist #사용 가능한 폰트 확인(상세정보포함)
#이것중에 골라서 찾아 써라
[f.name for f in fm.fontManager.ttflist] #글씨체만 알수있다.

plt.plot(x, y)
plt.title('꺽은선 그래프') #에러

plt.plot([-1, 0, 1], [-5, -1, 2])
# 한글폰트 사용시 마이너스 글자가 깨진다 설정해줘야함
#matplotlib.rcParams['axes.unicode_minus'] = False

plt.plot([-1, 0, 1], [-5, -1, 2])

2.軸
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams['font.family'] = 'Malgun Gothic' #windows
matplotlib.rcParams['font.size'] = 15
matplotlib.rcParams['axes.unicode_minus'] = False
x = [1, 2, 3]
y = [2, 4, 8]
plt.plot(x, y)
plt.title('꺽은선 그래프', fontdict = {'family': 'HYGungSo-Bold', 'size':20})
#폰트 개별 설정 가능

plt.plot(x,y)
# 축 이름 설정
plt.xlabel('x축', color = 'red') #색설정 - 이름으로
plt.ylabel('y축', color = '#00aa00') #색설정 - RGB로

# 위치설정
plt.plot(x,y)
plt.xlabel('x축', color = 'red', loc = 'right') # left, center, right
plt.ylabel('y축', color = '#00aa00', loc = 'top') # top, center, bottom

3.例
plt.plot(x, y, label= '무슨 데이터')
plt.legend()

plt.plot(x, y, label= '무슨 데이터') #범례위치변경
plt.legend(loc = 'upper right')

plt.plot(x, y, label= '무슨 데이터')
plt.legend(loc = 'lower left')

plt.plot(x,y,label='범례')
plt.legend(loc=(0.5, 0.5)) # x축, y축(0~1사이)

Reference
この問題について(データ分析と可視化), 我々は、より多くの情報をここで見つけました https://velog.io/@ssjy89/나도코딩-데이터-분석-및-시각화-Matplotlib1テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol