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

python3 でランダムな整数の配列を作る方法

random モジュールを使う。randint() の引数で、配列の最小値と最大値を指定できる。 例 import random random_arr = [random.randint(-2 …

no image

python3 で文字列を入力させて受け取る方法

C言語で scanf のようなものを作るには、python では input() で実現できる。 例 print(‘xの値を入力してください’) x = input() print(‘xの値は ‘ + …

no image

python3 で集合(set)の和集合を作る

集合にモノを付け足して和集合を作るには、|= 演算子を使う。(python では、集合(set)を波かっこで囲んで表す。) 例 a = {‘東京’} b = {‘大阪’,’千葉’} c = a | b …

no image

matplotlib で、ヒストグラムを作成する方法

ヒストグラムを描くには、data_hist を使う。 ヒストグラムの縦棒の数は bins で指定する。 例 from matplotlib import pyplot as plt data_hist …

no image

matplotlib で、矢印を描く方法

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