matplotlib python3

matplotlib でエラーバーを設定する方法

投稿日:

pyplot.errorbar を使って設定する。

オプションの詳細は

https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.errorbar.html

を参照。

import numpy as np
from matplotlib import pyplot as plt

def somefunc(x):
    return x*x*x - 2 * x*x + x - 3

x = np.linspace(-10, 10, num=30, endpoint=True)
y = somefunc(x)

fig, ax = plt.subplots()
ax.errorbar(x,y,fmt='.',color='blue',xerr=1,yerr=200,ecolor='red',capsize=2)

plt.show()

結果

-matplotlib, python3
-,

執筆者:


comment

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

関連記事

no image

matplotlib で、縦横の線(グリッド)を描く方法

pyplot grid で縦横線(罫線のようなもの)を引くことができる。 例 from matplotlib import pyplot as plt data_x = [25,26,27] …

no image

python3 で、dictionary のキー一覧を取得する方法

dict.keys() でキーを取得することができる。 参考:dictionary の値一覧を取得するときは、dict.values() を使う。 例 print(dict.keys())

no image

matplotlib の ax でx軸、y軸の端の値を設定する

axes には、set_xlim として定義する。 例 import numpy as np from matplotlib import pyplot as plt x = np.linspace( …

no image

matplotlib で、グラフ内に注釈ラベルをつける方法

annotate を使う 例 import numpy as np import matplotlib.pyplot as plt ax = plt.figure().add_subplot() th …

no image

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

リストを iter に変えたあと、… next() を使う。 参考リンク https://www.programiz.com/python-programming/methods/buil …