comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Y2 axis title orientation
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Y2 axis title orientation [message #74667] Sat, 29 January 2011 04:31 Go to next message
Jonathan is currently offline  Jonathan
Messages: 8
Registered: January 2011
Junior Member
To Paolo:
Your example shows exactly the problem I am talking about. Both axis
titles have their baselines on the right. My routine puts the baseline
on the left for the Y2 title.

To David:
You are certainly correct. You need to write the Y2TITLE command as a
procedure (comma, not parens). I had originally written it as a
function with the hope of finding a way of embedding it in a YTITLE
keyword. So the command should have read:

YTITLE, '5.0*COS(2!4p!3x/45 + 0.6)'

I have done some further testing, and so far it works with many ways I
apply a Y2 axis, including on a PostScript device.

--Jonathan

On Jan 28, 3:24 pm, David Fanning <n...@dfanning.com> wrote:
> Jonathan writes:
>> Today, I finally wrote a routine to correct this. I do not promise
>> that it is perfect, but I hope it is a step in the right direction,
>> and that with input from users of this group we can finally make a
>> usable y2 axis title routine.
>
> It would be more perfect if the example given in the
> documentation header actually worked. :-)
>
> 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: Y2 axis title orientation [message #74677 is a reply to message #74667] Fri, 28 January 2011 11:24 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Jonathan writes:

> Today, I finally wrote a routine to correct this. I do not promise
> that it is perfect, but I hope it is a step in the right direction,
> and that with input from users of this group we can finally make a
> usable y2 axis title routine.

It would be more perfect if the example given in the
documentation header actually worked. :-)

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: Y2 axis title orientation [message #74680 is a reply to message #74677] Fri, 28 January 2011 10:54 Go to previous messageGo to next message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
On Jan 28, 1:47 pm, Jonathan <jonat...@naic.edu> wrote:
> I have been occasionally frustrated by the inability to title a Y2
> axis (y-axis on the right side of a plot) with the right orientation.
> Using the command:
> AXIS,/SAVE,YAXIS=1,TITLE='title'
> writes the title with the baseline on the right, rather than the left.
> The latter is how I have always seen and used y2 axis titles, and it
> is a strange quirk of IDL that it insists on doing this in a non-
> standard (and in fact ugly) way.

That can be accomplished by using yaxis=0 instead of yaxis=1.

Example:

plot,[1,2,3]
AXIS,/SAVE,1,YAXIS=1,yTITLE='title' ;plot an axis with title on
right side
AXIS,/SAVE,1.5,YAXIS=0,yTITLE='title' ;left side version

Ciao,
Paolo


>
> Today, I finally wrote a routine to correct this. I do not promise
> that it is perfect, but I hope it is a step in the right direction,
> and that with input from users of this group we can finally make a
> usable y2 axis title routine.
>
> Here it is ...
> ;+
> ; NAME:
> ;   Y2TITLE
> ;
> ; PURPOSE:
> ;       The purpose of this routine is to print a right-hand y-axis
> title
> ;       with the baseline towards the axis (IDL's baseline is away
> from the axis).
> ;
> ; AUTHOR:
> ;
> ;   Jonathan Friedman
> ;   NAIC Arecibo Observatory
> ;   HC-3 Box 53995
> ;   Arecibo, PR 00612
> ; http://www.naic.edu
> ;   e-mail: jonat...@naic.edu
> ;
> ; CATEGORY:
> ;       Plotting, annotation and labeling.
> ;
> ; CALLING SEQUENCE:
> ;       Y2TITLE(titletext)
> ;
> ; INPUTS:
> ;       titletext:  The text that you want to use for the Y2 title.
> ;
> ; KEYWORD PARAMETERS:
> ;
> ;       ANGLE:    An angle for the text, CCW from vertical + baseline
> to the left
> ;                 in degrees.
> ;
> ;       CHARSIZE: The character size of the title. Default is 1.0.
> ;
> ;       COLOR:    The color index of the title. Default is !P.Color..
> ;
> ;       FONT:     Sets the font of the annotation. Hershey: -1,
> Hardware:0, True-Type: 1.
> ;
> ;
> ; COMMON BLOCKS:
> ;       None.
> ;
> ; SIDE EFFECTS:
> ;       The title is relative to the most recent PLOT call.
> ;
> ; RESTRICTIONS:
> ;       none.
> ;
> ; EXAMPLE:
> ;       To display a y2 title, type:
> ;
> ;       x=findgen(100)
> ;       y1=sin(2*!pi*x/30)
> ;       y2=5.*cos(2*!pi*x/45 + 0.6)
> ;       PLOT,x,y1,YRANGE=[-1,1],YSTYLE=3,YTITLE='SIN(2!4p!3x/30)'
> ;       AXIS,/SAVE,YAXIS=1,YRANGE=[-5,5],YSTYLE=3
> ;       OPLOT,x,y2,linestyle=2
> ;       Y2TITLE('5.0*COS(2!4p!3x/45 + 0.6)')
> ;
> ; MODIFICATION HISTORY:
> ;       Written by: Jonathan Friedman, 28 January 2011.
> ;-
> ;
> ;########################################################### ################
> ;
> ; LICENSE
> ;
> ;
> ; Copyright
> ;
> ; This software is provided "as-is", without any express or
> ; implied warranty. In no event will the authors be held liable
> ; for any damages arising from the use of this software.
> ;
> ; Permission is granted to anyone to use this software for any
> ; purpose, including commercial applications, and to alter it and
> ; redistribute it freely, subject to the following restrictions:
> ;
> ; 1. The origin of this software must not be misrepresented; you must
> ;    not claim you wrote the original software. If you use this
> software
> ;    in a product, an acknowledgment in the product documentation
> ;    would be appreciated, but is not required.
> ;
> ; 2. Altered source versions must be plainly marked as such, and must
> ;    not be misrepresented as being the original software.
> ;
> ; 3. This notice may not be removed or altered from any source
> distribution.
> ;
> ;
> ;########################################################### ################
>
> PRO y2title, text,ANGLE=angle,CHARSIZE=charsize,COLOR=color,FONT=font
>
> IF NOT KEYWORD_SET(ANGLE) then angle=0
>   ; coordinates of the plotting window in /NORMAL
> x0 = !x.window[0]
> x1 = !x.window[1]
> y0 = !y.window[0]
> y1 = !y.window[1]
> ch_nwidth = FLOAT(!D.X_CH_SIZE)/FLOAT(!D.X_VSIZE)
>
>   ; Determine the width of the y2 axis labels, and set the
>   ; position of the y2 axis title to the right of the labels.
> ylabel_val = ABS(!Y.CRANGE[1]) > ABS(!Y.CRANGE[0])
> ofs = (MIN(!Y.CRANGE) LT 0)? 3:2
> label_nwidth = CEIL(ABS(ALOG10(ylabel_val))) + ofs
> cs = (!P.CHARSIZE GT 0) ? !P.CHARSIZE*ch_nwidth : ch_nwidth
> xpos = (x1 + 0.01*(x1-x0)) + label_nwidth*cs
> ypos = (y1 + y0)/2
> XYOUTS,xpos,ypos,text,/NORMAL,ALIGNMENT=0.5, $
>        ORIENTATION=270+angle, $
>        CHARSIZE=charsize, COLOR=color, FONT=font
>
> END
Re: Y2 axis title orientation [message #74753 is a reply to message #74667] Mon, 31 January 2011 06:57 Go to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
On Jan 29, 7:31 am, Jonathan <jonat...@naic.edu> wrote:
> To Paolo:
> Your example shows exactly the problem I am talking about. Both axis
> titles have their baselines on the right. My routine puts the baseline
> on the left for the Y2 title.

What do you mean as "baseline"? I see one title on the right
of the axis, and one title on the left of the axis, isn't that
what you wanted? If not what is it you need?

Ciao,
Paolo

>
> To David:
> You are certainly correct. You need to write the Y2TITLE command as a
> procedure (comma, not parens). I had originally written it as a
> function with the hope of finding a way of embedding it in a YTITLE
> keyword. So the command should have read:
>
> YTITLE, '5.0*COS(2!4p!3x/45 + 0.6)'
>
> I have done some further testing, and so far it works with many ways I
> apply a Y2 axis, including on a PostScript device.
>
> --Jonathan
>
> On Jan 28, 3:24 pm, David Fanning <n...@dfanning.com> wrote:
>
>
>
>
>
>
>
>> Jonathan writes:
>>> Today, I finally wrote a routine to correct this. I do not promise
>>> that it is perfect, but I hope it is a step in the right direction,
>>> and that with input from users of this group we can finally make a
>>> usable y2 axis title routine.
>
>> It would be more perfect if the example given in the
>> documentation header actually worked. :-)
>
>> 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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: read a file written in fortran
Next Topic: Y2 axis title orientation

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 09:15:28 PDT 2025

Total time taken to generate the page: 0.00469 seconds