User Tools

Site Tools


python:matplotlib:基本的な使い方

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
python:matplotlib:基本的な使い方 [2018/01/20 21:53]
koudai
python:matplotlib:基本的な使い方 [2018/01/20 22:04]
koudai
Line 17: Line 17:
 import matplotlib.pyplot as plt import matplotlib.pyplot as plt
  
-x = np.arange(-np.pi, np.pi, 0.1) +x = np.arange(-np.pi, np.pi, 0.1)  # xを-πからπまで0.1刻みで用意する 
-y = np.sin(x)+y = np.sin(x)                      # y = sin x
  
-plt.plot(x, y) +plt.plot(x, y)   # 横軸をxとして y=y(x) のグラフをプロットする 
-plt.show()+plt.show()       # プロットしたグラフを画面に表示する
 </file> </file>
  
 +それぞれのコードの意味はコメントを参照してください。
 スクリプトができたら<code>$ python sin.py</code>を実行するとグラフが表示されます。 スクリプトができたら<code>$ python sin.py</code>を実行するとグラフが表示されます。
  
 +保存するにはグラフが表示されたウィンドウの上の方にあるフロッピーディスクのマークをクリックします(Ctrlキーを押しながらsを押すのでも可)。
 +
 +{{:intro1.png?direct&400|}}
  
  
python/matplotlib/基本的な使い方.txt · Last modified: 2021/06/27 22:04 (external edit)