Python Matplotlib で疑似カラー イメージ プロットを作成しようとしていますが、レイアウトに小さな問題があります。軸の目盛りラベルは非常に小さい数値 (1e-7 程度) であるため、Matplotlib は全体に指数を付けます。軸。これでもいいのですが、x軸のラベルとタイトルが重なっています!
タイトルを上向きに、xlabel を下向きにハッキングする以外に、これを修正するより良い方法はありますか?最大限のコードの再利用のため、Matplotlib にテキストの配置を手動で変更せずにこれを修正する方法があれば、それが最善です!
このプロットを生成する方法は次のとおりです。
fig = Figure(figsize=(5.5, 4.25))
ax = fig.add_subplot(111)
ax.set_title('The title', size=12)
ax.set_xlabel('The xlabel', size=10)
ax.set_ylabel('The Ylabel', size=10)
ax.ticklabel_format(scilimits=(-3,3))
pcm = ax.pcolor(X, Y, Z, cmap=cm.jet) #X,Y is a meshgrid and Z is the function evaluated on it
ax.get_figure().colorbar(pcm, ax=ax, use_gridspec=True)
ax.set_axes([0, 1e-3, -5e-7, 5e-7])
#Some code for the hatching at the top and bottom of the plot
for ticklabel in ax.get_xticklabels():
ticklabel.set_size(8)
for ticklabel in ax.get_yticklabels():
ticklabel.set_size(8)
ax.get_xaxis().get_offset_text().set_size(8)
ax.get_yaxis().get_offset_text().set_size(8)
fig.subplots_adjust()
c = FigureCanvas(fig)
c.print_figure('filename.png', dpi=300)