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種類のデータをプロットする方法

下では、凡例(legend)を設定している。 例 from matplotlib import pyplot as plt data_x = [25,26,27] data_y = [ …

no image

python3 でタプルを指定した要素で順に並び替える

タプルを、指定した要素で並び替えることができる。「key=lambda x 」で、引数 x を指定。lambda は無名関数を表す。 例 record = [(‘織田信長’, 1534, 15 …

no image

matplotlib でcsv ファイルを読み込むとき、最初の行をスキップする方法

numpy の loadtxt で読み込む行を省略したい場合 スキップしたい行を # 等の記号でコメントアウトして、 loadtxt の comments = ‘#’ とすると …

no image

matplotlib で、矢印を描く方法

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

no image

python3 で csv ファイルを読み込んで、最初の数行を表示する方法

以下の例では、空の配列 data を用意しておき、最初の3行を読み込んでおく。 例 import csv with open(‘data.csv’,’r’) as csv_file: csv_read …