python中plot不能显示标签_python:修改matplotlib中的标签行为

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()

如果我注释掉“minor=True”

^{pr2}$

主要刻度标签的日期显示正确(只有日期显示),但如果我取消注释(按原样),所有刻度标签都会显示,但在主要刻度上添加了“月-日-年”标签。我试着在所有刻度上只得到一天的日期(包括小刻度),没有任何“月-日-年”标签。在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值