matplot ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ๋ฐ์ดํฐ๋ฅผ ์ฐจํธ(chart)๋ ํ๋กฏ(plot) ํํ, 2D,3D๋ก ์๊ฐํํ๋๋ก ๊ธฐ๋ฅํฉ๋๋ค.
https://matplotlib.org/3.1.1/gallery/index.html
Gallery — Matplotlib 3.1.1 documentation
Gallery This gallery contains examples of the many things you can do with Matplotlib. Click on any image to see the full image and source code. For longer tutorials, see our tutorials page. You can also find external resources and a FAQ in our user guide.
matplotlib.org
์ ๋งํฌ์ ๊ณต์ ํํ์ด์ง์ ๋ค์ด๊ฐ๋ฉด, ๊ฐ์ข
์์ ๋ค์ด ๋ง์ด ์์ต๋๋ค. ๊ทธ์ค์ ๋ช๊ฐ์ง๋ฅผ ์๊ฐํ์๋ฉด,
Lines, bars and markers
Images, contours and fields
์ด ์ธ์๋. 3D ํ๋กฏํ
ํํ๋ ์ ๊ณตํฉ๋๋ค.
3D plotting
* pylab ์๋ธ ํจํค์ง
matplotlib์ ํ์์ pylab์ด๋ผ๋ ์๋ธํจํค์ง๊ฐ ์กด์ฌํฉ๋๋ค. (matplotlib๋ ์ ์ฒด๋ฅผ ํฌํจํ๋ ํจํค์ง์ด๋ฉฐ pylab์ matplotlib๋ฅผ ์ค์นํ๋ฉด ์๋์ผ๋ก ์ค์น๋๋ ๋ชจ๋์ค ํ๋์
๋๋ค.)
์์นํด์ ์ํํธ์จ์ด๋ก ์ ๋ช
ํ matlab์ ์๊ฐํ ๋ช
๋ น์ ํ์ด์ฌ์ผ๋ก ๊ตฌ๋ํ ์ ์๋๋ก ๊ตฌ์ฑ๋ ๋ช
๋ น์ด ์งํฉ์ ์ ๊ณตํฉ๋๋ค. ์ด๋ฅผ ์ด์ฉํด์ ๊ฐ๋จํ ์์ ๋ฅผ ๋ณด๊ฒ ์ต๋๋ค.
๊ธฐ๋ณธ์ ์ธ ๋ช
๋ น์ด
from matplotlib import pyplot as plt # plt๋ก ์ํฌํธํ๋๊ฒ ์ผ๋ฐ์ ์ด๋ผ๊ณ ํฉ๋๋ค. (์๋ฌด๊ฑฐ๋ํด๋์๊ด์๊ธด ํ์ง๋ง)
1.plt.xlabel(' ') - x์ถ ๋ ์ด๋ธ
2.plt.ylabel(' ') - y์ถ ๋ ์ด๋ธ
3.plt.title(' ') - ๊ทธ๋ํ ํ์ดํ
4.plt.legend(['๋ฒ๋ก_1 ', ' ๋ฒ๋ก_2 ']) - ๋ฒ๋ก ์ถ๊ฐ
5.plt.show() - ์๊ฐํ๋ช
๋ น
----------------------------------------------------------------------------------------------
6.plt.plot(x, y , color="blue" ) - ํ๋กฏ
7.plt.bar(x, y, width=0.7, color="blue" ) ๋ฐ ์ฐจํธ
8.plt.pie(x , y) ํ์ด์ฐจํธ
9.plt.hist(x, y ) ํ์คํ ๊ทธ๋จ
์์ ๊ธฐ๋ณธ ๋ช
๋ น์ด๋ฅผ ์ฌ์ฉํด์ ๋ค์ด๋ฒ๋ฅผ ์ฃผ๊ฐ๋ ์จ๋ฅผ ๋ณด๊ณ ์ธ์ฒ๊ณผ ์์ธ์ ์จ๋๊ทธ๋ํ๋ฅผ ๋ง๋ค์ด๋ณด์์ต๋๋ค.
from matplotlib import pyplot as plt
plt.xlabel(' Date ')
plt.ylabel(' Temperature')
plt.title(" Seoul&Inchon Temperature ")
in_temp = [9,5,7,6,-1]
sl_temp = [4,4,5,5,-3]
date = ["11/15","11/16","11/17","11/18,","11,19"]
plt.plot(date, in_temp, color = "green") #1
plt.plot(date, sl_temp , color= "Yellow") #2
plt.legend(['Inchon', 'Seoul']) #๋ฒ๋ก๋ ์ 1,2 ์์๋๋ก์ด๋ฏ๋ก ์์์ฃผ์
plt.show()