Hello everyone
I am trying to make a subplot with big and readable axis labels and ticks for a presentation.
So I modified the font size but now the y-axis label is outside the figure (see example figure).
Would you have any workaround to correct that ? The even better possibility would be to align the y labels but that is of second order of priority.
The code used to produce the figure is as follows :
a = np.arange(0,1000)
b = np.random.normal(15000, 1000, a.size)
c = np.random.normal(-15000, 1000, a.size)
fig = pygmt.Figure()
with pygmt.config(FONT_ANNOT=16, FONT_LABEL=18):
with fig.subplot(
nrows=2, ncols=1, figsize=("15c", "10c"), margins="0.5c",
):
with fig.set_panel(panel=0):
fig.basemap(projection="X?", region=[np.min(a), np.max(a), np.min(b), np.max(b)],
frame=['xaf+l"A in some units"', 'yaf+l"B in some units"'])
fig.plot(x=a, y=b)
with fig.set_panel(panel=1):
fig.basemap(projection="X?", region=[np.min(a), np.max(a), np.min(c), np.max(c)],
frame=['xaf+l"A in some units"', 'yaf+l"C in some units"'])
fig.plot(x=a, y=c)
fig.show()
Have a nice day !!
example.pdf (15.2 KB)
Smells of bad ghostscript. What is your ghostscript version?
The simplest check would be to update gs to the current version. I think 9.56 is the latest but most distros will have 9.55. We did have this but with some of the earlier gs versions, cannot recall if 9.50 was one of them but very likely.
Dear @pwessel
I could update my ghostscript version to v9.55.0 and v9.56.1
But the problem still persists for both versions.
Oh well, worth a try. Hopefully one of the pyGMT developers can comment further.
I can reproduce the issue using GMT CLI. Here is a minimal script:
gmt begin map
gmt set FONT_ANNOT=16 FONT_LABEL=18
gmt subplot begin 2x1 -Ff15c/10c -M0.5c
gmt basemap -JX? -R0/1000/12000/18000 -Bxaf+l"A in some units" -Byaf+l"B in some units" -c0
gmt basemap -JX? -R0/1000/-18000/12000 -Bxaf+l"A in some units" -Byaf+l"B in some units" -c1
gmt subplot end
gmt end show
I’m using GMT 6.5.0_548903e_2022.06.27
and gs 9.55.0 on Linux.
Intercepting the hidden gmt_o.ps- in the session dir before it completes shows it only moves the origin in to 1in, 1in. What happen to our GMT_PAPER_MARGIN_AUTO of 40 inches? If I make the edit and move the origin as intended then the rest works.
Will look at this later - have an all day event (seminar + dinner) today.
Somehow this gets set to the FIXED value:
double paper_margin = GMT_PAPER_MARGIN_AUTO;
if (gmtlib_fixed_paper_size (GMT->parent)) { /* Must honor paper size and regular margin */
paper_margin = GMT_PAPER_MARGIN_FIXED;
gmt_M_memcpy (media_size, GMT->current.setting.ps_def_page_size, 2, double);
}
Thanks for pointing this out. Fixed in master repo via this PR.
Dear @pwessel
Thank you very much for the support. I will try to reinstall soon the latest version from github in order to give you a (second) confirmation that the fix works.
Best regards