import matplotlib.pyplot as plt
list_x = [1,5,7,9,13,16]
list_y = [15,50,80,40,70,50]
plt.plot(list_x,list_y)
plt.show()
x跟y串列的數據量要一樣,否則會出現錯誤
x and y must have same first dimension, but have shapes (6,) and (5,)
顏色 | 值 |
---|---|
藍 | b,blue |
青 | c,cyan |
紅 | r,red |
洋紅 | m,megenta |
綠 | g,green |
黃 | y,yellow |
黑 | k,black |
白 | w,white |
plt.plot(list_x,list_y,color='r')
線條 | 值 |
---|---|
實線 | - |
虛線 | -- |
虛點線 | -. |
點線 | : |
plt.plot(list_x,list_y,ls='--')
plt.plot(list_x,list_y,lw=5)
節點形狀 | 值 |
---|---|
小點 | . |
大點 | o |
星星 | * |
正三角 | ^ |
倒三角 | v |
左三角 | < |
右三角 | > |
import matplotlib.pyplot as plt
list_x = [1,5,7,9,13,16]
list_y = [15,50,80,40,70,50]
#plt.plot(<第一組資料>,<第二組資料>[,])
#顏色color
#線條樣式linestyle/ls [-,--,-.,:]
#節點樣式marker
#節點大小markersize/ms
#組合用法 plt.plot(x,y,'g--*') g顏色(綠)--虛線*節點
plt.plot(list_x,list_y,'g--*')
plt.show()
#圖例名稱label
plt.plot(list_x,list_y,ls=":",lw=5,marker='*',label="tsmc")
#標題plt.title()
plt.title("0803_stock",fontsize=20)
#XY軸座標說明
plt.xlabel("time")
plt.ylabel("price")
plt.legend()
list1_x = [1,5,7,9,13,16]
list1_y = [15,50,80,40,70,50]
list2_x = [1,5,7,9,13,16]
list2_y = [60,80,75,77,90,83]
plt.plot(list1_x,list1_y,color='r',lw=3)
plt.plot(list2_x,list2_y,color='g',lw=3)
plt.show()
#顯示中文(改中文字體)
plt.rcParams["font.sans-serif"] = "mingliu"
plt.rcParams["axes.unicode_minus"] = False
plt.show()
內容: 很久很久以前,有一個國家叫做「正值國」,這個國家的人做什麼事都非常正直,做人坦蕩蕩。也因此,國家平安和樂、生活富足。
Mar 18, 2025https://github.com/tolgaatam/ColabTurtle
Mar 18, 2025list_a = list(range(1,20,2)) print(list_a) print(list_a[5]) list_a = [1,3,5,7,9,11,13,15,17,19] print(list_a) => [1,3,5,7,9,11,13,15,17,19]
Nov 6, 2022串列
Nov 6, 2022or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up