[英]Rotate x tick labels using subplots
As the title describes, I am using the subplots method to make bar charts. 如标题所述,我正在使用subplots方法制作条形图。 Everything works well but I can't figure out how to rotate the x tick labels.
一切正常,但我不知道如何旋转x刻度标签。 My graphing code is:
我的图形代码是:
f, axarr = plt.subplots(2, sharex=True)
axarr[0].set_xticklabels(file2_temp)
axarr[0].xaxis.set_ticks(y)
axarr[0].bar(np.arange(len(file_temp)), stddev_temp, align='center', alpha=0.4)
axarr[1].bar(np.arange(len(file_RH)), stddev_RH, align='center', alpha=0.4)
axarr[1].tick_params(axis='x', pad=30)
plt.show()
Where file2_temp and RH are lists and stddev_temp and RH are my data. 其中file2_temp和RH是列表,而stddev_temp和RH是我的数据。
Any help would be great. 任何帮助都会很棒。 Thanks!
谢谢!
You can rotate ticks using setp. 您可以使用setp旋转刻度线。
Here's an example modified from your your post: 这是您帖子中修改的示例:
import matplotlib.pyplot as plt
from numpy.random import rand
import numpy as np
f, axarr = plt.subplots(2, sharex=True)
axarr[0].bar(np.arange(1,11), rand(10), align='center', alpha=0.4)
axarr[1].bar(np.arange(1,11), rand(10), align='center', alpha=0.4)
axarr[1].tick_params(axis='x', pad=30)
plt.setp(plt.xticks()[1], rotation=45)
plt.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.