[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: xyouts character size to scale with the size of the plot window
- Subject: Re: xyouts character size to scale with the size of the plot window
 
- From: davidf(at)dfanning.com (David Fanning)
 
- Date: Sat, 4 Mar 2000 18:30:39 -0700
 
- Newsgroups: comp.lang.idl-pvwave
 
- Organization: Fanning Software Consulting
 
- References: <38C16F59.F6E68F0B@risoe.dk>
 
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:18787
 
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