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 で複数のグラフを並べて表示する方法

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

no image

matplotlib で、グラフの点の見た目を変更する方法

「marker」で指定すればよい。 次のページを参考に、plotの「marker」を変更する。 https://matplotlib.org/stable/api/markers_api.html 例 …

no image

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

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

no image

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

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

no image

matplotlib で折れ線グラフの下部に色をつけて塗りつぶす方法

pyplot の fill_between を使う。 例 from matplotlib import pyplot as plt data_x = [25,26,27] data_y = & …