简体   繁体   English

Matplotlib plot 上的奇怪 x 标签

[英]Matplotlib weird x labels on plot

fig = plt.figure(figsize=(40,5))
ax1 = fig.add_subplot(111)
ax2 = ax1.twiny()

ax1.plot(time_stamps,b,"b.--",label="Status")
ax1.plot(time_stamps,d,"y.--",label="Process")
ax2.set_xlim(ax1.get_xlim())
ax1.set_xlim(ax2.get_xlim())

mymajorformat = mdates.DateFormatter('%H:%M')
myminorFormat = mdates.DateFormatter('%H:%M')



ax1.xaxis.set_major_locator
(MinuteLocator(byminute=range(0,60,5)))


ax2.xaxis.set_minor_locator
(MinuteLocator(byminute=range(0,60,60)))

ax2.tick_params(axis='x',which="minor",length=10, 
rotation=30,labelsize=12)
ax1.tick_params(axis='x',which="major",length=10, 
rotation=90,labelsize=11)
ax1.xaxis.set_major_formatter(mymajorformat)
ax2.xaxis.set_minor_formatter(myminorFormat)

ax2.set_xticks(ax1.get_xlim())

I am not allowed to include images.我不允许包含图像。 As you can see i have a weird x description (red box) on beginning and end of plot also on bottom x axis at the end.如您所见,我在 plot 的开头和结尾处也有一个奇怪的 x 描述(红色框),也在底部的 x 轴上。 How to hide this?如何隐藏这个?

enter image description here在此处输入图像描述

this is working这是有效的

ax2.set_xticks([]) ax2.set_xticks([])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM