未分類

matplotlib で x軸・y軸ラベルをつける

投稿日:

plt.xlabel と plt.ylabel を使う。

import numpy as np
import matplotlib.pyplot as plt

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

plt.xlabel('x axis')
plt.ylabel('y axis')
plt.title("title")
plt.show()

結果

-未分類

執筆者:


comment

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

関連記事

no image

python3 で range からリストを生成する方法

list をrange を指定して初期化すれば良い。数を1つ飛ばしのリストも次のようにして作れる。 例 list1 = list(range(1,10,2)) print(list1) 結果 [1, …

no image

tex で文字を上付きにした矢印を入力する方法

\overset を使う方法がある。 例 $\overset{\text{abc}}{\rightarrow}$ 結果

no image

tex で大括弧を表示する

大括弧を表示するには、\left[ または \right] を使う。 例 $\left[ \left( \frac{x}{y} \right) \right]$ 結果 片方だけの大括弧 片方だけのカッ …

no image

tex で数式モード内に普通の文字列を入力する方法

\textrm を使う。 例 $$y = f (x) \hspace{1cm} \textrm{This is a function.}$$ 結果

no image

python3 でリストから重複を削除したリストを作成する方法

いったん dictionary に変換してから、新しいリストを作成する。すると、重複を除いたリストが作れる。 例 list1 = [‘1′,’2′,’3′,’1′,’2′,’5’] dict1 = d …