We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 715257a commit 078fca4Copy full SHA for 078fca4
D18_matplotlib/homework.py
@@ -0,0 +1,26 @@
1
+import pandas as pd
2
+import matplotlib.pyplot as plt
3
+import numpy as np
4
+
5
+# 1. 畫出 cos 圖檔,並儲存
6
+x = np.arange(0,360)
7
+y = np.cos(x*np.pi/180.0)
8
+plt.plot(x,y, color = 'red')
9
10
+ # 照需要寫入x 軸和y軸的 label 以及title
11
+plt.xlabel("x-axis")
12
+plt.ylabel("y-axis")
13
+plt.title("Cos graphic")
14
+plt.savefig("cos.png",dpi=300,format="png")
15
+plt.show()
16
17
+# 2. 給定散點圖顏色
18
+X = np.random.normal(0, 1, 100)
19
+Y = np.random.normal(0, 1, 100)
20
+plt.scatter(X, Y, color = 'gold')
21
+plt.title("Scatter plot")
22
23
+# 如果要存成圖形檔:
24
+# 把 pyplot.show() 換成下面這行:
25
+plt.savefig("Scatter.png",dpi=300,format="png")
26
0 commit comments