On Thu, 18 Apr 2002, Sean Davis wrote:
> I'm not sure I understand how to find where the XTITLE would have been
> placed on the plot, in the monochrome case. If you knew where the XTITLE
> would have been placed, then it seems that using XYOUTS would work great.
>
> For example, the monochrome case would be
>
> PLOT, findgen(20), xtitle = 'This is a cool title'
>
> It seems to me you're saying that if I wanted the word 'cool' to be blue,
> I could do the following:
>
> 1. PLOT, findgen(20)
>
> 2. Break the title string into 3 strings
>
> 3. Make 3 calls to XYOUTS
>
> So my question is, how would I know the correct positions to send to
> XYOUTS so that the xtitle appears in the same place as it would as if I
> had just called
>
> PLOT, findgen(20), xtitle='this is a cool title'
>
> ???
The answer to your question is: "use the WIDTH= keyword from XYOUTS"
I put the code below into "title.pro", and call it this way:
IDL> title, findgen(20), 'This is a cool title', 'cool', chars=2, charth=3
IDL> plot, findgen(20), xtitle='This is a cool title', /NOERASE, $
chars=2, charth=3
NOTE: if you do not see any difference when overplot with the
PLOT,/NOERASE command, that is because on my computer it is producing
the *exact* same output...
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;
PRO title, data, title, word, _EXTRA=e
;;; set up the plot
plot, data, _EXTRA=e
;;; get the length of the title
xyouts, 10, 10, title, /norm, width=width, _EXTRA=e
;;; calculate the middle of the X-AXIS of the plot
mid_axis_data = (!x.crange[1] + !x.crange[0]) / 2.
mid_axis_norm = $
(convert_coord([mid_axis_data,mid_axis_data],/data,/to_norm) )[0]
x_title = mid_axis_norm - (width/2.)
;;; set up the 3 titles
title_norm = strsplit( title, word, /extract, /regex )
title_color = word
;;; draw the 3 titles
xyouts, x_title, 0.02, title_norm[0], /norm, width=w0, _EXTRA=e
xyouts, x_title+w0, 0.02, title_color, /norm, width=w1, color=10, _EXTRA=e
xyouts, x_title+w0+w1, 0.02, title_norm[1], /norm, _EXTRA=e
END
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;
--
------------------------------------------------------------ ---------------
Ken Mankoff http://lasp.colorado.edu/snoe/
http://lasp.colorado.edu/mars/
http://lasp.colorado.edu/~mankoff/ http://lasp.colorado.edu/marsrobot/
------------------------------------------------------------ ---------------
|