python:matplotlib:基本的な使い方
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
python:matplotlib:基本的な使い方 [2018/01/21 00:25] – koudai | python:matplotlib:基本的な使い方 [2021/06/27 22:04] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 29: | Line 29: | ||
{{: | {{: | ||
- | 保存するにはグラフが表示されたウィンドウの上の方にあるフロッピーディスクのマークをクリックします(Ctrlキーを押しながらsを押すのでも可)。 | + | 保存するにはグラフが表示されたウィンドウの上の方にあるフロッピーディスクのマークをクリックします([Ctrl-s]も可)。 |
- | + | ||
- | あるいはplt.savefigを使うとファイルに直接出力できます。 | + | |
- | + | ||
- | <file python> | + | |
- | import numpy as np | + | |
- | import matplotlib.pyplot as plt | + | |
- | + | ||
- | x = np.arange(-5, | + | |
- | y = np.sin(x) | + | |
- | + | ||
- | plt.plot(x, y) | + | |
- | plt.savefig(" | + | |
- | </ | + | |
- | + | ||
- | 保存できる形式は | + | |
- | * emf | + | |
- | * eps | + | |
- | * jpeg | + | |
- | * jpg | + | |
- | + | ||
- | * png | + | |
- | * ps | + | |
- | * raw | + | |
- | * rgba | + | |
- | * svg | + | |
- | * svgz | + | |
- | * tif | + | |
- | * tiff | + | |
- | です。 | + | |
- | formatを指定しない場合、ファイル形式は拡張子により自動判別されます。 | + | |
Line 74: | Line 44: | ||
y1 = np.sin(x) | y1 = np.sin(x) | ||
y2 = np.cos(x) | y2 = np.cos(x) | ||
- | |||
- | plt.title(" | ||
- | plt.xlabel(" | ||
- | plt.ylabel(" | ||
- | |||
- | plt.plot(x, y1, label=" | ||
- | plt.plot(x, y2, label=" | ||
- | plt.legend() | ||
plt.xlim(-np.pi, | plt.xlim(-np.pi, | ||
Line 105: | Line 67: | ||
x = np.arange(-5, | x = np.arange(-5, | ||
y = np.sin(x) | y = np.sin(x) | ||
+ | |||
plt.title(" | plt.title(" | ||
plt.xlabel(" | plt.xlabel(" | ||
- | plt.ylabel(" | + | plt.ylabel(" |
plt.plot(x, y) | plt.plot(x, y) | ||
Line 167: | Line 130: | ||
import matplotlib.pyplot as plt | import matplotlib.pyplot as plt | ||
- | x = [1, | + | x = [1,2,3, 4, 5, 6, 7, 8, 9, 10] |
- | y = [1, | + | y = [1, |
plt.title(" | plt.title(" |
python/matplotlib/基本的な使い方.1516461917.txt.gz · Last modified: 2021/06/27 21:59 (external edit)