Re: Using PS_START to create A4 Landscape postscript? [message #77869] |
Fri, 30 September 2011 08:09 |
rjp23
Messages: 97 Registered: June 2010
|
Member |
|
|
On Sep 30, 12:36 am, David Fanning <n...@dfanning.com> wrote:
> What you are doing here is setting the page size
> and orientation of the plot. You are not doing
> anything to set the "window" on the PostScript
> page where the plot will be located.
>
> Presumably "it doesn't seem to work" means you
> don't like the defaults PS_Start is choosing for
> you. If so, then by all means choose your own.
> The XSIZE, YSIZE, XOFFSET and YOFFSET keywords
> are the ones you want to use.
Ah I see now. I didn't realise the differentiation between the window
and the device. Thanks again :-)
|
|
|
Re: Using PS_START to create A4 Landscape postscript? [message #77873 is a reply to message #77869] |
Thu, 29 September 2011 16:36  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Rob writes:
> I'm sure this is simple but I can't quite get it to work.
>
> I want to create an A4 landscape postscript file where the plot takes
> up the entire window (i.e. no margins).
>
> I thought I could do this: PS_Start, FILENAME='plot.ps', chasize=1,
> landscape=1, page='A4' but it doesn't seem to work.
>
> I specifically don't want to use the psconfig GUI as this needs to run
> in a loop and create multiple plots, but I thought I could set the
> keywords in ps_start without needing to use ps_config.
>
> Can someone point me in the right direction?
What you are doing here is setting the page size
and orientation of the plot. You are not doing
anything to set the "window" on the PostScript
page where the plot will be located.
Presumably "it doesn't seem to work" means you
don't like the defaults PS_Start is choosing for
you. If so, then by all means choose your own.
The XSIZE, YSIZE, XOFFSET and YOFFSET keywords
are the ones you want to use.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: Using PS_START to create A4 Landscape postscript? [message #77874 is a reply to message #77873] |
Thu, 29 September 2011 14:28  |
Matthew
Messages: 18 Registered: February 2006
|
Junior Member |
|
|
I have found that this does not provide enough space on the left side
of the plot for the title on the y axis. This is because the number of
characters used to label the tickmarks is different depending on your
scale. I am continuing to fiddle with it.
|
|
|
Re: Using PS_START to create A4 Landscape postscript? [message #77875 is a reply to message #77874] |
Thu, 29 September 2011 12:42  |
Matthew
Messages: 18 Registered: February 2006
|
Junior Member |
|
|
You can try something like this:
device, 'ps', filename='A4.ps', xsize=21.0/2.54 , ysize=29.7/2.54, /
inches
A4 paper is 210x297mm and there are 2.54cm/inch. To remove the
margins, you will have to do some work. After you make your last call
to DEVICE (as above), you can try the following. Define "margins" to
be a 4 element vector: [left_margin, bottom_margin, right_margin,
top_margin] where *_margin are the widths of the margins in normal
coordinates. In your case [0.0, 0.0, 1.0, 1.0].
This bit of code calculates the region and window of the plot (read
about ![xyz].region, ![xyz].window, !p.region, !p.window) in the IDL
help files. The end result, "position" will give you the location of
the plot in normal coordinates that you can pass to PLOT, etc.
Note that I have tried this in the display window, but not for ps
plots yet. I have to call PLOT to initialize the system variables
related to plots (!p and ![xyz]).
margins_norm = margins
;initialize the plot region
plot, !x.range, !y.range, /nodata, /noerase, xstyle=4, ystyle=4
;convert the margins from normal coordinates to device coordinates
;this would be useful for printing square plots to preserve aspect
ratio
margins_dev = margins_norm
margins_dev[0] = margins_norm[0] * !d.x_vsize
margins_dev[2] = margins_norm[2] * !d.x_vsize
margins_dev[1] = margins_norm[1] * !d.y_vsize
margins_dev[3] = margins_norm[3] * !d.y_vsize
;character size in normal coordinates
xcharsize = !d.x_ch_size / !d.x_vsize
ycharsize = !d.y_ch_size / !d.y_vsize
;Calculate the size of the plotting region. This is the total area of
the plot,
;including axis labels and titles
x_region = fltarr(2)
y_region = fltarr(2)
x_region[0] = 0.0 + margins_norm[0]
x_region[1] = 1.0 - margins_norm[2]
y_region[0] = 0.0 + margins_norm[1]
y_region[1] = 1.0 - margins_norm[3]
p_region = [x_region[0], y_region[0], x_region[1], y_region[1]]
;Calculate the size of the plot window. This is the region contained
within the
;axes and does not include title, ticklabels, etc.
;Note that the main title is 1.25 times larger than the normal font
size.(ycharsize*1.25).
;the axes need room for tick labels AND axis titles (xcharsize*2.0),
;and the x-axis title/offset subtracts from the space in the y-
direction
x_window = fltarr(2)
y_window = fltarr(2)
x_window[0] = x_region[0] + myttl_offset + xcharsize*2.0
x_window[1] = x_region[1] ;no labels on the right side of
the region
y_window[0] = y_region[0] + mxttl_offset + ycharsize*2.0
y_window[1] = y_region[1] - mttl_offset - ycharsize*1.25
p_window = [x_window[0], y_window[0], x_window[1], y_window[1]]
;calculate the height and width of each individual plot window
plot_width = (p_window[2] - p_window[0]) / ncols
plot_height = (p_window[3] - p_window[1]) / nrows
positions[0] = p_window[0]
positions[1] = p_window[1]
positions[2] = p_window[0] + plot_width
positions[3] = p_window[1] + plot_height
|
|
|