未分類

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 で図の番号を表示しない方法

caption パッケージを使っておき、\caption* を使うと、図の番号を表示しないようにできる。 例 \usepackage{caption} \begin{document} \begin{ …

no image

tex で文字の上の点を入力する方法

テキストモードでは \. 数式モードでは \dot{} を使う。 例 \.{a}$\dot{x}$ 結果

no image

tex と分数

tex で分数を入力するには、frac を使います。 \frac{2}{3} 表示結果 次のように表示されてしまう場合は、バッククォート(\ マーク)が抜けているのが原因です。 間違った場合。

no image

tex で小文字のL(リットル)記号を入力する方法

tex で小文字のL(l)リットル記号を入力するには、\ell を使う。通常の小文字の l は、\\l であるのに注意。 例 5 \\ell 結果

no image

python3 で、文字列のパーセント(%)をそのまま表示する方法

文字列の始まりに r をつけて、raw 文字列にするとパーセントなどの文字をそのまま表示できる。 例 str1 = r’%s%d\t’ print(str1) 結果 %s%d\t