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

matplotlib で複数のグラフを並べて表示する方法

plot.subplots() でグラフの縦方向と横方向の数を指定する。 例 import numpy as np from matplotlib import pyplot as plt x1 = …

no image

python3 でリストの要素を None に変更する方法

要素を None に変更すればよい。 例 arr = [1,2,3,4,5] print(str(arr)) for i in range(len(arr)): arr[i] = No …

no image

python3 で、フォルダがなければ作成するプログラム

os.mkdir() 関数を使う。 すでにフォルダが存在している場合は、エラーを表示する。 例 import os folder_name = ‘./python_create_folder’ try …

no image

matplotlib で、2次関数のグラフを描画する方法

2次関数のグラフを表示するには次のようにする。 例 import matplotlib.pyplot as plt import numpy as np # numpy linspace 等間隔な数列 …

no image

matplotlib で、矢印を描く方法

arrowprops のパラメータは次を参考にして設定できる。 https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.FancyAr …