0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【備忘録】Pythonでグラフ作成

Posted at

大学の課題でグラフを作成する必要があり,Pythonを使用した.以前も同じようにPythonのmatplotlibを使用してグラフを書く機会があり,今後も多くなりそうなため,備忘録として書き残すことにした.

以下に今回用いたコードを掲載する.

graph.py
import matplotlib.pyplot as plt
import numpy as np

# データの準備
x = np.linspace(0, 80, 100)
y1 = 8*x*x
y2 = 64*x*np.log2(x)

# 描画
plt.plot(x, y1, color='blue', label='8*x^2')
plt.plot(x, y2, color='red', label='64*x*log2(x)')

# 軸とタイトル
plt.xlabel('x')
plt.ylabel('y')
plt.title('graph')
plt.legend()

# 表示
plt.show()

実行はPowerShell7を用いた.

PowerShell 7(x64)
python graph.py

実行結果
スクリーンショット 2025-10-15 190341.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?