Closed Barney-9000 closed 1 year ago
I post this here, since it's presumably related. Using xsize
and ysize
with device
results in a substantially distorted aspect ratio. A minimal example is:
pro iso, eps=eps
if keyword_set(eps) then begin
set_plot, 'ps'
device, xsize=24., ysize=8., file="./iso.eps", /encap
endif
plot, [0],[0], xr=[-1,1], yr=[-1,1], xsty=1, ysty=1, /isotropic, /nodata
oplot, [-1,1],[1,-1]
oplot, [-1,1],[-1,1]
return
end
@GillesDuvert : I've traced the aspect-ratio-issue down to commit d6a8e4e55fdfe5111081e715050743378b3605cf from two years ago. Since I'm unfamiliar with PostScript dimensions/units, I was wondering whether you have a clue what might be the cause of the issue...
I believe some (most?) of the problem is due to the 'padding' around text produced by the standard margins in plplot when the postscript driver is enabled -- the defined plot area expands to accommodate these (too wide?) margins. This seems to happen whenever text (e.g. plot labels, XYOUTS, etc.) appears near to the edges of the eps graphic, and particularly evident when the text is large. Whereas with IDL, whatever the size/position of the characters, any part of the text outside the plot area is clipped. See attached PDFs. With chars=1.0 for the XYOUTS command printing the software name in capitals, the GDL eps graphic has the same dimensions and plot positions as the IDL eps graphic (not shown). However, with chars=5.0, the GDL eps graphic now gets extra padding left, right and top -- even though the text is clipped outside of the defined plot area (black border). Red border shows extend of each eps graphic. So, a workaround if you're fussy about exact plot positioning on eps graphics that keep to the defined size, is to keep the plots a little distance away from the edges of the eps graphic, and watch out for large character text. With a little bit of attention to that, I managed to get my multiple plot GDL eps graphics to keep to the same dimensions/layout as the IDL eps graphics.
The fact that the text in the GDL eps graphic is correctly clipped suggests perhaps that there's a fix if plplot could be coaxed into ignoring the standard margins that stray outside the defined eps area. Outside of my expertise, I'm afraid, to delve into the relevant code.
thank you @Barney-9000 for the analysis. newly submitted #1638 aims to insure correct positioning of boxes and shapes, even on real printers, but was not addressing directly this issue. It would be nice to check however if the 'bug' is still present.
the new merged version should reproduce almost exactly IDL's PS output, whatever the page xsize and ysize, the color/b&W, encapsulated/not encap, font size, thickness of lines, position of images, etc. Please test.
Tried it just now with today's version compiled/installed on macOS 11.7.10 using 'Way 1'. Any attempt to output to the PS device now causes a crash:
GDL> SET_PLOT, 'PS'
GDL> PLOT, HANNING(50)
% Compiled module: HANNING.
*** PLPLOT WARNING ***
Option 'epsf' not recognized.
Recognized options for this driver are:
text: Use Postscript text (text=0|1)
color: Use color (color=0|1)
hrshsym: Use Hershey symbol set (hrshsym=0|1)
Program aborted
@Barney-9000 did you 'make install'? Because 'epsf' is a new option introduced in the GDL version of the plplot driver. Necessary to replicate IDL's behaviour of /encapsulated. So the ps.so driver compiled with the last version should be installed in /usr/local/share/gnudatalanguage/drivers/, that is normally done when installing.
Ah, that fixed it! Hadn't spotted that change. Agreement with IDL plots generally more precise. However, large characters can still 'bloat' the PS area -- see attachments. Also, something (similarly?) odd happening with title/subtitle size and placement -- title/subtitle only applied for the GDL-Charsi-3.0 plot. GDL-Charsi-0.3.pdf GDL-Charsi-1.0.pdf GDL-Charsi-3.0.pdf
Concerning the placement of axis titles, in particular the Y axis positioning is currently false (too wide) and in fact I realized that and started working on it. This is not restricted to the PS driver. Concerning the 'bloating', I'm sorry to ask, but it would be more convincing if the GDL and IDL plots were superposed to show the differences. (or have a copy of the procedure used to make the plot). On linux, I just customize the following procedure, that calls itself using IDL, producing two plots, and combine them using the following procedure:
pro superpose,x,y,idl=idl ; you can pass any useful values
if isa(idl) then add='idl_' else add=''
; do something
a=dist(256)
; here I test 2 PS outputs, a PORT and a LAND
set_plot,'ps'
device,/port,xsize=x,ysize=y,file=add+"port.ps" & plots,[0,0,1,1,0],[0,1,1,0,0],/norm & plot,dist(10),/noer,/nodata
tv,a,xsize=60,ysize=4,0,4,/data
device,/close
device,/land,xsize=x,ysize=y,file=add+"land.ps" & plots,[0,0,1,1,0],[0,1,1,0,0],/norm & plot,dist(10),/noer,/nodata
tv,a,xsize=60,ysize=4,0,4,/data
device,/close
if not isa(idl) then begin
spawn,'(source /opt/idl/idl84/bin/idl_setup.bash; /opt/idl/idl84/bin/idl -e "superpose,/idl,'+string(x)+","+string(y)+'")'
endif
spawn,'ps2pdf port.ps ; ps2pdf idl_port.ps; pdftk port.pdf background idl_port.pdf output combined_port.pdf'
spawn,'ps2pdf land.ps ; ps2pdf idl_land.ps; pdftk land.pdf background idl_land.pdf output combined_land.pdf'
end
producing combined_port.pdf
and combined_land.pdf
A recent recompile of GDL (28/03/23 -- macOS 11.7.5 intel) now results in postscript graphics that deviate markedly from the (centimetre) dimensions specified in the DEVICE command. For example, a postscript graphic which should be 18x24cm is output by GDL at 15.7 × 24.73 cm. An example from IDL & GDL attached. GDL always was a little bit out, but now the deviation its quite a bit larger. This may be a recurrence of a boxsize related oddity fixed in 2021 #1002. Interestingly, the two plots in the GDL graphic have the correct dimensions and exact relative position, see graphic with the two graphics superposed.
All the best -- and many thanks for keeping GDL alive and kicking!
IDL.pdf GDL.pdf GDL-IDL-superposed.pdf