"Pyplot"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(다른 사용자 한 명의 중간 판 10개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
;matplotlib.pyplot
{{소문자}}
;Pyplot, matplotlib.pyplot
;파이플롯
 
{{소스헤더|짧은 테스트 코드}}
<syntaxhighlight lang='python' run>
import matplotlib.pyplot as p;p.boxplot((1));p.show()
</syntaxhighlight>


==화면 출력==
==화면 출력==
<source lang='python'>
<syntaxhighlight lang='python' run>
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.ylabel('some numbers')
plt.show()
plt.show()
</source>
</syntaxhighlight>
[[File:pyploy-some numbers.png]]


<source lang='python'>
<syntaxhighlight lang='python' run>
import numpy as np
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
x = np.linspace(0,10,1000)
x = np.linspace(0,10,1000)
y = np.power(x,2)
y = np.power(x,2)
22번째 줄: 27번째 줄:
plt.ylabel('y')
plt.ylabel('y')
plt.show()
plt.show()
</source>
</syntaxhighlight>
 
[[파일:pyplot1-x2.png]]


==PDF 파일로 저장==
==PDF 파일로 저장==
<source lang='python'>
<syntaxhighlight lang='python'>
import numpy as np
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
38번째 줄: 41번째 줄:
plt.ylabel('y')
plt.ylabel('y')
plt.savefig('test_plot.pdf')
plt.savefig('test_plot.pdf')
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
44번째 줄: 47번째 줄:


==참고==
==참고==
* https://matplotlib.org/tutorials/introductory/pyplot.html
* https://matplotlib.org/3.1.1/tutorials/introductory/pyplot.html
* https://matplotlib.org/3.1.1/tutorials/introductory/pyplot.html


[[분류: matplotlib]]
[[분류: Pyplot]]

2021년 3월 14일 (일) 17:00 기준 최신판

1 개요[ | ]

Pyplot, matplotlib.pyplot
파이플롯
짧은 테스트 코드
Python
CPU
1.0s
MEM
49M
1.2s
Copy
import matplotlib.pyplot as p;p.boxplot((1));p.show()
Traceback (most recent call last):
  File "runbox.py", line 1, in <module>
    import matplotlib.pyplot as p;p.boxplot((1));p.show()
  File "/usr/local/lib/python3.8/site-packages/matplotlib/pyplot.py", line 2691, in boxplot
    return gca().boxplot(
  File "/usr/local/lib/python3.8/site-packages/matplotlib/__init__.py", line 1361, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/usr/local/lib/python3.8/site-packages/matplotlib/axes/_axes.py", line 3745, in boxplot
    bxpstats = cbook.boxplot_stats(x, whis=whis, bootstrap=bootstrap,
  File "/usr/local/lib/python3.8/site-packages/matplotlib/cbook/__init__.py", line 1190, in boxplot_stats
    X = _reshape_2D(X, "X")
  File "/usr/local/lib/python3.8/site-packages/matplotlib/cbook/__init__.py", line 1419, in _reshape_2D
    if len(X) == 0:
TypeError: object of type 'int' has no len()
Command exited with non-zero status 1

2 화면 출력[ | ]

Python
Copy
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()
Loading
Python
Copy
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0,10,1000)
y = np.power(x,2)
plt.plot(x,y)
plt.title('main title')
plt.xlabel('x')
plt.ylabel('y')
plt.show()
Loading

3 PDF 파일로 저장[ | ]

Python
Copy
import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0,10,1000)
y = np.power(x,2)
plt.plot(x,y)
plt.title('main title')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig('test_plot.pdf')

4 같이 보기[ | ]

5 참고[ | ]