未分類

matplotlib で縦横の罫線を出力する

投稿日:

罫線を出力するには、pyplot.grid を使う。

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 2, 100)
plt.plot(x, x, label='linear')
plt.plot(x, x*x, label='quad')

plt.xlabel('x axis')
plt.ylabel('y axis')
plt.grid(color='b', linestyle=':', linewidth=0.3)
plt.title("title", color='rebeccapurple')
plt.legend()
plt.show()

結果

参考

https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.grid.html

-未分類

執筆者:


comment

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

関連記事

no image

tex で「デルタ」δ・Δ を入力する方法

小文字のデルタ:δ大文字のデルタ:Δ 例 $\delta, \Delta$ 結果

no image

python3 で文字列を区切り文字を指定してリストに変換する方法

split メソッドを使う。 例 str1 = ‘this, is, a, pen’ str2 = str1.split(‘,’) print(str2) 結果 [‘this’, ‘ is’, ‘ a …

no image

c++ で文字列をファイルに保存する方法

result.txt というファイルに “data1 data2 data3” という内容を保存する。ofstream を使って書き出す。 例 #include<iost …

no image

tex で frac の意味

tex で frac コマンドは、分数(fraction)を表示するために使う。「バックスラッシュを付けた」 \frac であることに注意。 例 $\frac{2}{3}$ 結果

no image

tex 大なり・小なり記号

tex で、「大なり」「小なり」を入力する方法通常の「大なり」「小なり」記号 例 $>$ $<$ 結果 参考 不等号を含むもの(大なりイコール・小なりイコール)を入力することもできる。イコールは …