顏色設置之ax與fig
fig與ax是有區別的. 兩者的顏色設置都可以在創建的時候設置.
fig = plt.figure(facecolor = '#2C2D39')
ax = fig.add_subplot(111,facecolor = '#2C2D39')
很容一看出來, fig的範圍和ax的範圍, 以及兩者設置顏色的方法.
顏色設置之label, tick
ax.tick_params(axis='both',color='r',labelcolor='g')
axis='both'
代表修改x, y 座標中的兩個.
color='r',labelcolor='g'
前者代表修改tick的顏色, 後者修改座標軸數字的顏色
顏色設置之spines(座標軸)
想設置x軸和y軸的顏色嗎, 請看
ax.spines['right'].set_color('None')# 右框不顯示
ax.spines['top'].set_color('None')# 上框不顯示
ax.spines['left'].set_color('g')# 左框綠色
ax.spines['bottom'].set_color('b')# 下框藍色
顏色設置之數據線
ax.plot(data ,c='g')
直接畫圖時傳入c的值