【发布时间】:2021-04-03 01:54:26
【问题描述】:
我有两个长长的 xticks,带有扭曲的情节。底部标签看起来不错!两个问题:
- 标签看起来像是被剪掉了。
- 顶部标签远侧指向刻度,如何调整近侧指向刻度? (使用不同的旋转?)
#!/usr/bin/env python3
import matplotlib.pyplot as plt
import pandas as pd
fig = plt.figure()
ax = fig.add_subplot(111)
df1 = pd.DataFrame()
idx = 0
for i in range(1,50):
df1.loc[idx,'name'] = 'AAAAAAAAAA' + str(i)
df1.loc[idx,'value'] = 40*i
idx += 1
df2 = pd.DataFrame()
idx = 0
for i in range(1,50):
df2.loc[idx,'name'] = 'BBBBBBBBBB' + str(i)
df2.loc[idx,'value'] = i*i
idx += 1
ax2 = ax.twiny()
df1.plot(x='name',y='value',ax=ax)
df2.plot(x='name',y='value',ax=ax2)
fig.autofmt_xdate(rotation=45)
#plt.savefig(pngname)
plt.show()
【问题讨论】:
-
@BigBen 谢谢,已更新
标签: python matplotlib