2018年1月17日 星期三

matplotlib ---- figure3 線條顏色

matplotlib ---- figure3 線條顏色

#使用import導入模組matplotlib.pyplot,並簡寫成plt
#使用import導入模組numpy,並簡寫成np
import matplotlib.pyplot as plt
import numpy as np

#使用np.linspace定義x:範圍是(-1,1);個數是50. 模擬一維資料組(x ,y)表示曲線1.

x = np.linspace(-3, 3, 50)
y1 = 2*x + 1
y2 = x**2

#使用plt.figure定義一個圖像視窗. 使用plt.plot畫(x ,y)曲線. 使用plt.show顯示圖像.


#使用plt.figure定義一個圖像視窗:編號為3;大小為(8, 5). 使用plt.plot畫(x ,y2)曲線. 使用plt.plot畫(x ,y1)曲線,曲線的顏色屬性(color)為紅色;曲線的寬度(linewidth)為1.0;曲線的類型(linestyle)為虛線. 使用plt.show顯示圖像.
plt.figure(num=3, figsize=(8, 5),)
plt.plot(x, y2)
plt.plot(x, y1, color='red', linewidth=1.0, linestyle='--')
plt.show()


沒有留言:

張貼留言

2024年4月24日 星期三 Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --2

 2024年4月24日 星期三 Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --2 AngularJS 實例 <!DOCTYPE html> <html> <head> &...