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

gnuplot で、グラフの形を正方形にする方法

set size square または、その省略形で set size sq というコマンドを使えば正方形の中にグラフを描くことができる。 例 set size square plot cos(x) …

no image

python3 で、フォルダがなければ作成するプログラム

os.mkdir() 関数を使う。 すでにフォルダが存在している場合は、エラーを表示する。 例 import os folder_name = ‘./python_create_folder’ try …

no image

matplotlib で、2次関数のグラフを描画する方法

2次関数のグラフを表示するには次のようにする。 例 import matplotlib.pyplot as plt import numpy as np # numpy linspace 等間隔な数列 …

no image

python3 で、すべて小文字かどうかを判定する方法

islower() 関数を使う。 例 print(‘abcde’.islower()) print(‘abcDe’.islower()) 結果 True False

no image

python3 で辞書からタプルを作成する

辞書に対して、items() メソッドを使うと、タプルを作成することができる。 例 cities = {‘東京’:1000,’大阪’:700, ‘広島’:100} for a,b in cities. …