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

我不允許包含圖像。 如您所見,我在 plot 的開頭和結尾處也有一個奇怪的 x 描述(紅色框),也在底部的 x 軸上。 如何隱藏這個?

在此處輸入圖像描述

這是有效的

ax2.set_xticks([])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM