Description
The x-ticks (and respective labels) for some of my subplot axes are re-scaled in the output png files.
While I didn't find this exact problem posted elsewhere, perhaps it's related to:
#12564
I say that b/c, the above image was my standard export at 300 dpi while I get my expected result at 120 dpi (below):
Changing the figsize changes the expression of the problem, but doesn't make it go away (e.g. 300 dpi at 14 x 20):
I also consulted :
[(https://github.com//issues/6800)]
[(https://github.com//issues/6638)]
but they are different expressions (of possibly a similar underlying problem) than mine.
I find it particularly odd that the minor x-ticks seem to stay put while the major x-ticks (and respective labels) shift.
Minimally reproducible code (with min/maxima of x-values in my data series plotted as points):
fig = plt.figure(constrained_layout=True, figsize=(10, 14))
# create top/bottom subfigs
(subfig_t, subfig_b) = fig.subfigures(2, 1, hspace=0.01, height_ratios=[3, 7])
# put ax0 in top subfig
ax0 = subfig_t.subplots()
# create left/right subfigs nested in bottom subfig
(subfig_bl, subfig_br) = subfig_b.subfigures(1, 2, wspace=0.01, width_ratios=[7, 2])
# put ax1-ax3 in gridspec of bottom-left subfig
gs = subfig_bl.add_gridspec(nrows=1, ncols=14)
ax1 = subfig_bl.add_subplot(gs[0, :1])
ax1.scatter(x=[-56.46881504821776, 24.179891162109396], y=[1500, 3600])
ax2 = subfig_bl.add_subplot(gs[0, 1:3], sharey=ax1)
ax2.scatter(x=[-126.5357270050049, 94.68456736755368], y=[1500, 3600])
ax3 = subfig_bl.add_subplot(gs[0, 3:14], sharey=ax1)
ax3.scatter(x=[-638.323228561402, 878.5568315887451], y=[1500, 3600])
ax2.set_ylabel('')
ax2.set_yticklabels([])
ax3.set_ylabel('')
ax3.set_yticklabels([])
b1_xlab = subfig_bl.supxlabel("MyLabel", x=0.5, size=12, fontweight='bold')
b1_xlab._autopos = True
# put ax4 in bottom-right subfig
ax4 = subfig_br.subplots()
ax4.scatter(x=[-36.00010414731702, 46.8026446716616], y=[1500, 3600])
subfig_br.supxlabel(' My Other Label', size=12, fontweight='bold')
dpi_lst = [120, 300]
for d in dpi_lst:
out_plot = out_path + "MyFile_{}.png".format(d)
plt.savefig(out_plot, dpi=d, transparent=True)
Any suggestions for a work-around?
Operating system
Windows 10 Pro
Matplotlib Version
3.4.2
Python version
3.9.5
Jupyter version
3.0.16
Installation
conda
Conda channel
conda-forge