Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
804 views
in Technique[技术] by (71.8m points)

python - Rotate minor ticks in matplotlib

I am plotting the following chart :

enter image description here

with the following code:

fig, ax = plt.subplots(figsize=(20, 3))
mpf.candlestick_ohlc(ax,quotes, width=0.01)
ax.xaxis_date()
ax.xaxis.set_minor_locator(mpl.dates.HourLocator(interval=4) )
ax.xaxis.set_minor_formatter(mpl.dates.DateFormatter('%H:%M')) 
plt.xticks(rotation = 90)

plt.grid(True)
plt.show()

I would like to also rotate the minor ticks: How would i do that?

Subsidiary question is there a way to rotate both major and minor tick with a single command?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You may rotate by code of one line plt.setp(ax.xaxis.get_minorticklabels(), rotation=90).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...