未分類

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

c++ で文字列を合成(連結)する方法

c言語では、sprintf 関数を使って文字列を合成(連結)することができる。いっぽう、c++ では、文字列を string で表して「+」演算子で文字列を合成することができる。 例 #include …

no image

mac の convert コマンドで画像ファイルをサイズ変更する

convert コマンドを使うには、imagemagick というソフトがインストールされていることが必要。 インストールの確認 $ which convert で、imagemagick がインスト …

no image

tex で差集合の記号を入力する方法

\setminus を使う。 例 $A \setminus B$ 結果

no image

tex で email を書く方法

\hyperref パッケージを使って次のように書く。 例 \usepackage{hyperref} \begin{document} \href{mailto:taro@example.co.jp …