0
plt.rc('axes', grid=True)
plt.rc('grid', color='0.75', linestyle='-', linewidth=0.5)
textsize = 9
left, width = 0.1, 0.8
rect1 = [left, 0.7, width, 0.2]
fig = plt.figure(facecolor='white')
axescolor = '#f6f6f6' # the axes background color
ax1 = fig.add_axes(rect1, axisbg=axescolor) #left, bottom, width, height
### plot the relative strength indicator
rsi = RSI(GOOG,20) #rsi[0] is list of float, rsi[1] is list of datetime objects
rsiValues = rsi[0]
rsiDate = rsi[1]
ticker = 'GOOG'
fillcolor = 'darkgoldenrod'
ax1.plot(rsiDate, rsiValues, 'kx') #, fmt='bo', tz=None, xdate=True, ydate=False,color=fillcolor)
ax1.axhline(70, color=fillcolor)
ax1.axhline(30, color=fillcolor)
#ax1.fill_between(rsiDate, rsiValues, 70, where=(rsiValues>=70),facecolor=fillcolor, edgecolor=fillcolor)
#ax1.fill_between(rsiDate, rsiValues, 30, where=(rsiValues<=30), facecolor=fillcolor, edgecolor=fillcolor)
ax1.text(0.6, 0.9, '>70 = overbought', va='top', transform=ax1.transAxes, fontsize=textsize)
ax1.text(0.6, 0.1, '<30 = oversold', transform=ax1.transAxes, fontsize=textsize)
ax1.set_ylim(0, 100)
ax1.set_yticks([30,70])
ax1.set_xticks(rsiDate,minor = True)
#just want day date
tickLabels = []
for items in rsiDate:
tickLabels.append(items.day)
ax1.set_xticklabels(tickLabels, rotation = 45,minor = True)
ax1.text(0.025, 0.95, 'RSI (20)', va='top', transform=ax1.transAxes, fontsize=textsize)
ax1.set_title('%s daily'%ticker)
plt.show()
修改標籤的行爲如果我註釋掉「小=真」蟒蛇:在matplotlib
ax1.set_xticklabels(tickLabels, rotation = 45)#,minor = True)
爲主要刻度標記當天日期顯示正常(只有一天的日期顯示),但如果我取消它(原樣)所有刻度標籤都會顯示,但在主要刻度上添加了「每月一天」標籤。我試圖在沒有任何'月 - 日 - 年'標籤的所有蜱(包括未成年人)上僅獲得日期日期。