python - 在 matplotlib 中旋转小刻度

标签 python matplotlib

我正在绘制以下图表:

enter image description here

使用以下代码:

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

我还想旋转小刻度线:我该怎么做?

附属问题有没有办法用一个命令同时旋转主要和次要刻度?

最佳答案

你可以通过一行代码plt.setp(ax.xaxis.get_minorticklabels(), rotation=90)进行旋转。

关于python - 在 matplotlib 中旋转小刻度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41390487/

相关文章:

python - 如何使用 cron 表达式安排数据管道在每个月的第一个星期二运行,然后在 5 天后的夜间 cet 运行

python - 如何在 request.post 方法中使用 json 和 files 参数上传文件

python - python 2.7中的FFMPEG文件编写器

python - 如何根据两个选定的 Pandas 系列绘制 ​​CDF 图

python - Matplotlib - 在单元格中创建一个带有线图的表格?

python - 使用python在3d图中叠加图像

python - Matplotlib:带有光栅化图的多页 PDF

python - 当输入等级为 4 时,使用哪种 tensorflow 批标准化代码?

python - Azure 认知服务和 Python 可执行文件

python - 如何输入风速和风向数据并在 python 中将其绘制在同一个图上?