2013-03-01 200 views
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) 

为主要刻度标记当天日期显示正常(只有一天的日期显示),但如果我取消它(原样)所有刻度标签都会显示,但在主要刻度上添加了“每月一天”标签。我试图在没有任何'月 - 日 - 年'标签的所有蜱(包括未成年人)上仅获得日期日期。

回答

0
ax1.tick_params(which='major', axis = 'x', labelbottom = 'off') 

添加这一行代码的作品。