3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【python】Sinカーブのグラフをかく

Last updated at Posted at 2019-10-26

コード#

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 2*np.pi, 500)

plt.plot(x,np.sin(x))
plt.show()

図#

sin.PNG

説明##

必要なライブラリ##

ライブラリ 用途
matplotlib グラフを描画するために必要
numpy いろいろな計算をするのに必要

x軸の数値##

x = np.linspace(0, 2*np.pi, 500)

np.linspaceは等差数列を生成する関数です.
上記の例では, 0から2$\Pi$ の範囲で500個のnumpy配列を生成しています.

表示##

plt.plot(x,np.sin(x))
plt.show()

plt.plot(x,y)で表示したいデータをx,yに格納します.
今回はy=sin x を計算するためにnp.sin(x)yのところに書いてますね.

参考#

NumPy で数学系の関数を使ってみよう
線形に等間隔な数列を生成するnumpy.linspace関数の使い方

3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?