相关疑难解决方法(0)

使用twiny时,Python Matplotlib图标题与轴标签重叠

我试图使用twiny在同一图表上绘制两个单独的数量,如下所示:

fig = figure()
ax = fig.add_subplot(111)
ax.plot(T, r, 'b-', T, R, 'r-', T, r_geo, 'g-')
ax.set_yscale('log')
ax.annotate('Approx. sea level', xy=(Planet.T_day*1.3,(Planet.R)/1000), xytext=(Planet.T_day*1.3, Planet.R/1000))
ax.annotate('Geostat. orbit', xy=(Planet.T_day*1.3, r_geo[0]), xytext=(Planet.T_day*1.3, r_geo[0]))
ax.set_xlabel('Rotational period (hrs)')
ax.set_ylabel('Orbital radius (km), logarithmic')
ax.set_title('Orbital charts for ' + Planet.N, horizontalalignment='center', verticalalignment='top')


ax2 = ax.twiny()
ax2.plot(v,r,'k-')
ax2.set_xlabel('Linear speed (ms-1)')

show()
Run Code Online (Sandbox Code Playgroud)

并且数据显示得很好,但我遇到的问题是图形标题与辅助x轴上的轴标签重叠,因此它几乎不易读(我想在这里发布图片示例,但我没有足够高的代表).

我想知道是否有一种简单的方法可以直接将标题移动几十个像素,这样图表看起来更漂亮.

python matplotlib title figure

128
推荐指数
6
解决办法
15万
查看次数

标题使用 matplotlib 和 pandas - python

知道为什么我下面的脚本将标题放置在离图表/子图这么远的地方吗?是否可以指定标题的字体大小?

df = pandas.read_csv('data.csv', delimiter=',', 
                             index_col=0, 
                             parse_dates=[0], dayfirst=True, 
                             names=['Date','1','2','3','4', '5'])

        df.plot(subplots=True, marker='.',markersize=8, title ="Graph", fontsize = 10, color=['r','b','b','b', 'b'], figsize=(8, 18))


        plt.savefig('capture.png')
Run Code Online (Sandbox Code Playgroud)

万分感谢!

python matplotlib pandas

0
推荐指数
1
解决办法
4654
查看次数

标签 统计

matplotlib ×2

python ×2

figure ×1

pandas ×1

title ×1