์ƒˆ์†Œ์‹

๐Ÿ ํŒŒ์ด์ฌ (Python)

<matplotlib> (pylab) - 2D, 3D ๋ฐ์ดํ„ฐ ์ž๋ฃŒ ์‹œ๊ฐํ™”

  • -

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() 

 

Contents

ํฌ์ŠคํŒ… ์ฃผ์†Œ๋ฅผ ๋ณต์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค

์ด ๊ธ€์ด ๋„์›€์ด ๋˜์—ˆ๋‹ค๋ฉด ๊ณต๊ฐ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.