matplotlib python3

matplotlib で、線の種類を変更する方法

投稿日:

「linestyle = 」として、線の種類を指定することができる設定の詳細は、次のリンクを参照。

https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html

from matplotlib import pyplot as plt

data_x = [25,26,27]
data_y = [39,41,50]
data_y2 = [40,20,17]

plt.plot(data_x,data_y, linestyle='dotted',label='dotted line')
plt.plot(data_x,data_y2, linestyle='dashed',label='dashed line')
plt.legend()

plt.grid(True)

plt.show()

結果

-matplotlib, python3
-,

執筆者:


comment

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

関連記事

no image

pythonで配列(リスト)の、ある要素がわかっているときにその次の要素を取得する方法。

next() を使う。 例 my_arr = [‘春’,’夏’,’秋’,’冬’] my_iter = iter(my_arr) print(next(my_iter,’なし’)) print(next …

no image

python3 でリストを結合する方法

2つのリストを結合して、「リストのリストを作りたい場合」と、「1つの長いリストを作りたい」場合がある。 それぞれ、次のようにする。 例 # リスト2つを用意 l_1 = [1,2,3] l_2 …

no image

matplotlib で、x,y の軸上の数値を表示する方法

ax の xtics と ytics を使って表示する。 詳細は次のドキュメントを参照。 https://matplotlib.org/stable/gallery/lines_bars_and_ma …

no image

python のプロンプトについて

UNIX で python を起動する ターミナルで $ python インタープリターのプロンプトは >>> となっている。 インタープリタを終了させるときは、Ctrl + D を押す。

no image

matplotlib でグラフの背景の色を変える方法(facecolor)

次のように、axes で facecolor を変更すればよい。 例 from matplotlib import pyplot as plt x = [2,7,8] y = [7,1 …