0
我正在按照YouTube上的教程創建燭臺圖表,並遇到了一個有趣的問題。本教程顯示,您可以通過直接更改matplotlib finance.py文件來編輯燭臺線顏色。 finance.py文件中的原始代碼如下所示:Python Matplotlib如何調整燭臺陰影顏色?
lines = []
patches = []
for q in quotes:
t, open, close, high, low = q[:5]
if close>=open :
color = colorup
lower = open
height = close-open
else :
color = colordown
lower = close
height = open-close
vline = Line2D(
xdata=(t, t), ydata=(low, high),
color='k',
linewidth=0.5,
antialiased=True,
)
請注意vline部分。以下是經過調整後的代碼:
lines = []
patches = []
for q in quotes:
t, open, close, high, low = q[:5]
if close>=open :
color = colorup
lower = open
height = close-open
vline = Line2D(
xdata=(t, t), ydata=(low, high),
color=colorup,
linewidth=0.5,
antialiased=True,
)
else :
color = colordown
lower = close
height = open-close
vline = Line2D(
xdata=(t, t), ydata=(low, high),
color=colordown,
linewidth=0.5,
antialiased=True,
)
'''vline = Line2D(
xdata=(t, t), ydata=(low, high),
color='k',
linewidth=0.5,
antialiased=True,
)'''
至於原因,我無法理解的陰影仍然顯示爲黑色。我已經嘗試過兩種配置。
- Windows XP中的Python 2.7蟒蛇分佈Matplotlib 1.3
- Windows 7中的Python 2.7的Python(XY)分佈Matplotlib 1.3
任何幫助表示讚賞。謝謝。