美文网首页
pyplot x-axis label rotation

pyplot x-axis label rotation

作者: 榴莲气象 | 来源:发表于2019-01-19 20:31 被阅读6次

Python pyplot x-axis label rotation

setp looks to be the way to go with pyplot (inspiration from this answer). This works for me:

import matplotlib.pyplot as plt
import seaborn as sns; sns.set()
import numpy as np; np.random.seed(0)

data = np.random.rand(10, 12)
ax = sns.heatmap(data)
ax.xaxis.tick_top()
locs, labels = plt.xticks()
plt.setp(labels, rotation=90)
plt.show()

Obviously I don't have your data, hence the numpy random data, but otherwise the effect is as required:

[图片上传失败...(image-3cd4d1-1547900983689)]

shareedit

相关文章

网友评论

      本文标题:pyplot x-axis label rotation

      本文链接:https://www.haomeiwen.com/subject/ykozdqtx.html