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 で2種類のcsvファイルをプロットする方法

data1.csv と、data2.csv の2つのファイルを散布図としてプロットするには次のようにする。 例 import numpy as np from matplotlib import py …

no image

python3 で整数の割り算、商と余りを求める方法

floor divisionを使う。 例 a = 15 // 7 b = 15 % 7 print(a) print(b) 結果 2 1

no image

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

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

no image

matplotlib で、凡例を表示する位置を変更する方法

凡例(legend)の表示位置を変更するには、axis の legend の loc を設定する。 次のリンクhttps://matplotlib.org/stable/api/_as_gen/mat …

no image

matplotlib のプロットスクリプト内で計算する方法

gnuplot の場合 gnuplot では、plot “data.txt” u 1:($2*2)などと書くと、 数値を加工(データ値を使った計算)を行った結果をグラフ化するこ …