未分類

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 で三角形の相似記号を入力する

\sim を使う。 例 $\triangle{ABC} \sim \triangle{DEF}$ 結果

no image

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

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

no image

tex で累乗根を入力する方法

$\sqrt[n]{2}$のようにする。 例 $\sqrt[n]{2}$ 結果

no image

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

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

no image

python3 で、ファイルの文字列の1行目を出力する

ファイルを読み込んで、1行目だけをコンソールに出力するには readlines() を使う。 例 f = open(“data.txt”) lines = f.readlines() print(li …