Re: xyouts character size to scale with the size of the plot window [message #19176] |
Mon, 06 March 2000 00:00 |
Ralf Srama
Messages: 2 Registered: December 1999
|
Junior Member |
|
|
Kristian,
I think you need to know how many plots you have on
one page. You can access this by
a=!p.multi[1] ;i.e. 3 in your example
b=!p.multi[2] ;i.e. 7 in your example
c=a*b ;21
factor=0.01
xyouts,7,3,'STRING',/data,charsize=.7-factor*c ;results in a
;smaller character depending on your number of plots on
;the screen
You can now play with the factor for your needs.
Alternatively you could use the system variable !p.clip. It
contains the coordinates of the last plot on the device.
In the example below you have for the first plot the numbers
30 and 290. This is a difference of 260 for the x-size of
your last plot. This difference is constant for the following
plots (e.g. 329 and 589).
!P.CLIP
The device coordinates of the clipping window, a 6-element vector of the
form [(x0, y0, z0), (x1, y1, z1)], specifying two opposite corners of
the volume to be displayed. In the case of two-dimensional displays, the
Z coordinates can be omitted. Normally, the clipping window coordinates
are implicitly set by PLOT, CONTOUR, SHADE_SURF, and SURFACE to
correspond to the plot window. You may also manually set !P.CLIP if you
want to specify a different rectangular clipping window or if the
clipping coordinates have not yet been set in the current IDL session.
IDL> plot, indgen(200)
IDL> print,!p.clip
30 704 290 811 0 1000
IDL> plot,indgen(200)
IDL> print,!p.clip
329 704 589 811 0 1000
Ralf Srama
Kristian Kjaer wrote:
>
> I hope this is not a too FAQ:
>
> IDL> !p.multi=0
> IDL> plot,indgen(10)
> IDL> xyouts,7,3,'A string',/data,charsize=.7 ; Gives text reasonably
> sized for my purpose
> IDL> !p.multi=[0,3,7]
> IDL> plot,indgen(10)
> IDL> xyouts,7,3,'A string',/data,charsize=.7 ; Gives text which is too
> large for the window.
>
> How to get the xyouts character size to scale with the size of the plot
> window?
>
> Thanks for any help.
> Best regards, Kristian Kj�r
--
ralf.srama@mpi-hd.mpg.de Tel 49-6221 516 423 Fax 49-6221 516 324
Max-Planck-Institut fuer Kernphysik, Saupfercheckweg 1, 69117
Heidelberg, Germany
CDA-Homepage http://galileo.mpi-hd.mpg.de/cassini
Dust-Group http://galileo.mpi-hd.mpg.de
|
|
|
Re: xyouts character size to scale with the size of the plot window [message #19192 is a reply to message #19176] |
Sat, 04 March 2000 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Kristian Kjaer (kristian.kjaer@risoe.dk) writes:
> I hope this is not a too FAQ:
>
> IDL> !p.multi=0
> IDL> plot,indgen(10)
> IDL> xyouts,7,3,'A string',/data,charsize=.7 ; Gives text reasonably
> sized for my purpose
> IDL> !p.multi=[0,3,7]
> IDL> plot,indgen(10)
> IDL> xyouts,7,3,'A string',/data,charsize=.7 ; Gives text which is too
> large for the window.
>
> How to get the xyouts character size to scale with the size of the plot
> window?
I've always had pretty could luck using my Str_Size program,
which I wrote to size the annotation of plots in resizeable
graphics windows. Your application is different from what I had
in mind, although I think Str_Size can be adapted for it. I'm
not sure there is any reliable way to *always* get correctly
sized characters. Too much depends on such other factors, such as
the size of the window, personal aesthetics, etc.
Str_Size works by specifying a string and a "target width"
of that string in the display window. The target width is
given in normalized coordinates. I thought dividing the
target width by the number of columns in the multi-plot
worked reasonably well:
************************************************************ *******
PRO EXAMPLE
window, xsize=500, ysize=500
!p.multi=0
plot,indgen(10)
; Normal target size.
largeCharsize = Str_Size('A String', 0.15)
xyouts,7,3,'A string',/data,charsize=largeCharsize
!p.multi=[0,3,7]
window, 1, xsize=500, ysize=500
; Target size divided by number of columns.
smallCharsize= Str_Size('A String', 0.15/!p.multi[1])
for j=0,20 do begin
plot,indgen(10)
xyouts,7,3,'A string',/data,charsize=smallCharsize
endfor
!P.multi=0
END
************************************************************ *******
You can find Str_Size here:
http://www.dfanning.com/programs/str_size.pro
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|