未分類

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 でかけ算の記号 x (✕)を表示する

かけ算記号を表示するには、$\times$ を使う。 例 $2 \times 3$ 結果

no image

tex 表の一部の列のみを中央揃えにする

中央揃えにしたい列を、c で指定すればよい。その他は l (左)または r (右)揃えに指定する 例 \begin{table} \begin{tabular}{ |r|c|r|} \hline Ta …

no image

X(twitter) 時期を指定して検索する方法

X/Twitter の検索窓に次のように打ち込むことで、条件を指定して、絞り込んだポストを表示することができる。 日付を指定する since:2022-02-22 until:2022-02-23 あ …

no image

h バー(プランク定数)の書き方

量子科学では、「プランク定数」を h で表すが、h を 2π で割った量を エイチバーで表すことがある。 tex での書き方 $\hbar$ 結果 リベンジH 4【電子書籍】[ 仙道ますみ ]価格:6 …

no image

tex で文字色を RGB で指定する

文字色を RGB で指定する。例では、\definecolor で、「samplecolor」という色を定義して使っている。 例 \usepackage{xcolor}\begin{document} …