Skip to content

Instantly share code, notes, and snippets.

@PeaceAndHiLight
Created August 15, 2017 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PeaceAndHiLight/085b10c92353cb0c68aaf0fc5d45532b to your computer and use it in GitHub Desktop.
Save PeaceAndHiLight/085b10c92353cb0c68aaf0fc5d45532b to your computer and use it in GitHub Desktop.
matplotlibによるグラフ表示
# coding:utf-8
import numpy as np
import matplotlib.pyplot as plt
# 0から6まで0.1刻みで配列に格納する
x = np.arange(0, 6, 0.1)
# xの値を入力に、sinとcosの配列を作る
y1 = np.sin(x)
y2 = np.cos(x)
# pyplotの機能でグラフ表示
plt.plot(x,y1,label="sin")
plt.plot(x,y2,linestyle="--", label="cos")
plt.xlabel("x")
plt.ylabel("y")
plt.title('sin & cos')
plt.legend()
plt.show()
@PeaceAndHiLight
Copy link
Author

matplotlibのpyplotの機能でsinとcosのグラフを表示させます。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment