there is something i want to do

折れ線グラフ
matplotlibモジュールの「plot」を利用することで、折れ線グラフを表示する。
Syntax
Syntax
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plot
import numpy as npy
# x軸のラベル
plot.xlabel("X")
# y軸のラベル
plot.ylabel("Y")
x = ["A","B","C","D","E","F"]
y1 = npy.random.rand(6) * 10
y2 = npy.random.rand(6) * 10
y3 = npy.random.rand(6) * 10
# 折れ線グラフ
plot.title("line")
plot.plot(x,y1, marker="o", color = "red", linestyle = "--",lw=2,label="RedLine")
plot.plot(x,y2, marker="v", color = "green", linestyle = "-.",lw=1,label="GreenLine")
plot.plot(x,y3, marker="^", color = "blue", linestyle = "-.",lw=1,label="BlueLine")
# グリッドの表示
plot.grid(True)
# 凡例の表示
# labelで指定されたものが表示される
plot.legend()
plot.show()
Comment
Comment
import matplotlib でパッケージをインポートする。
matplotlibのパッケージをインポートすることで、plot()の関数が使用可能になる
Example
#
#cat test.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plot
import numpy as npy
# x軸のラベル
plot.xlabel("X")
# y軸のラベル
plot.ylabel("Y")
x = ["A","B","C","D","E","F"]
y1 = npy.random.rand(6) * 10
y2 = npy.random.rand(6) * 10
y3 = npy.random.rand(6) * 10
# 折れ線グラフ
plot.title("line")
plot.plot(x,y1, marker="o", color = "red", linestyle = "--",lw=2,label="RedLine")
plot.plot(x,y2, marker="v", color = "green", linestyle = "-.",lw=1,label="GreenLine")
plot.plot(x,y3, marker="^", color = "blue", linestyle = "-.",lw=1,label="BlueLine")
# グリッドの表示
plot.grid(True)
# 凡例の表示
# labelで指定されたものが表示される
plot.legend()
plot.show()
#
#python test.py
#

折れ線グラフ