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

Home » Public Forums » archive » Re: save axis
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: save axis [message #72032] Wed, 04 August 2010 06:05
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
Chris,
thanks for helping me out. I considered Option 1 and then dismissed it
for lack of elegance. :-) Option 2 makes sense, not as simple as I had
hoped for, but at least it works.

I still think that the plot title moving as a result of the
axs.yrange=[0,1] command is a bug. I thought we had a similar exchange
a while ago, but I am not entirely sure that this was the same issue.
It may have been on moving x/y titles instead.

Cheers,
Haje


On Aug 3, 5:55 pm, Chris Torrence <gorth...@gmail.com> wrote:
> On Aug 3, 12:35 pm, Haje Korth <hajeko...@gmail.com> wrote:
>
>> one more quirk. th efull plot code I use is
>
>>     plt=plot(loc,hist,/
>> histogram,xrange=[0,100],yrange=[0,0.2],color='black',linest yle='solid',thick=2.5,$
>>       xtitle='AC
>> Count',ytitle='N',title=region_a[i],axis_style=1,margin=[0.1 5,0.15,0.15,0.15])
>>     axs=axis('Y',location=[100,0],title='Cum.
>> Probability',color='red',tickdir=0,textpos=1)
>>     axs.yrange=[0,1]
>
>> As soon as I set the axis range, the title set in plt call moves to
>> 0.2 in the middle of the plot. grrrrr.
>
>> H
>
> Hi Haje,
>
> The new AXIS function works a bit differently than the direct graphics
> procedure. With the new graphics, the AXIS function cannot be used to
> change the plot range (i.e. there is no equivalent to the SAVE
> keyword).
>
> Instead, you have two different routes you can take.
>
> 1. You can embed the new axis in the existing plot (like you were
> doing). To make this work, you will need to force the tick names to
> match the desired range. For example:
> axs=axis('Y',location=[100,0],title='Cum. Probability', $
>   color='red',tickdir=0,textpos=1, $
>   tickvalues=[0,0.1,0.2], $
>   tickname=['0', '0.5', '1.0'])
> Obviously this gets trickier when you have a varying Y range (not just
> hardcoded to 0 - 0.2).
>
> 2. The better way is to create a new plot coordinate system. This way
> you could have a new X and Y range (if you wanted), and you could even
> plot a second line. Here is some sample code:
>
> loc = 10*findgen(11)
> hist = 0.2*randomu(seed,11)
> plt = barplot(loc,hist,bottom_values=hist, $
>   xrange=[0,100],yrange=[0,0.2], $
>   color='black',linestyle='solid',thick=2.5, $
>   xtitle='AC Count',ytitle='N',$
>   axis_style=1,margin=[0.15,0.15,0.15,0.15])
>
> ; Create a new plot coordinate system
> newDS = plot([0,100],[0,1],/current, /nodata, $
>   margin=[0.15,0.15,0.15,0.15], axis_style=0)
> axs=axis('Y',location=[100,0],title='Cum. Probability', $
>   target=newDS, $
>   color='red',tickdir=0,textpos=1)
>
> Note the /nodata in the PLOT call.
>
> Hope this helps.
>
> Cheers,
> Chris
> ITTVIS
Re: save axis [message #72038 is a reply to message #72032] Tue, 03 August 2010 14:55 Go to previous message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
On Aug 3, 12:35 pm, Haje Korth <hajeko...@gmail.com> wrote:
> one more quirk. th efull plot code I use is
>
>     plt=plot(loc,hist,/
> histogram,xrange=[0,100],yrange=[0,0.2],color='black',linest yle='solid',thick=2.5,$
>       xtitle='AC
> Count',ytitle='N',title=region_a[i],axis_style=1,margin=[0.1 5,0.15,0.15,0.15])
>     axs=axis('Y',location=[100,0],title='Cum.
> Probability',color='red',tickdir=0,textpos=1)
>     axs.yrange=[0,1]
>
> As soon as I set the axis range, the title set in plt call moves to
> 0.2 in the middle of the plot. grrrrr.
>
> H

Hi Haje,

The new AXIS function works a bit differently than the direct graphics
procedure. With the new graphics, the AXIS function cannot be used to
change the plot range (i.e. there is no equivalent to the SAVE
keyword).

Instead, you have two different routes you can take.

1. You can embed the new axis in the existing plot (like you were
doing). To make this work, you will need to force the tick names to
match the desired range. For example:
axs=axis('Y',location=[100,0],title='Cum. Probability', $
color='red',tickdir=0,textpos=1, $
tickvalues=[0,0.1,0.2], $
tickname=['0', '0.5', '1.0'])
Obviously this gets trickier when you have a varying Y range (not just
hardcoded to 0 - 0.2).

2. The better way is to create a new plot coordinate system. This way
you could have a new X and Y range (if you wanted), and you could even
plot a second line. Here is some sample code:

loc = 10*findgen(11)
hist = 0.2*randomu(seed,11)
plt = barplot(loc,hist,bottom_values=hist, $
xrange=[0,100],yrange=[0,0.2], $
color='black',linestyle='solid',thick=2.5, $
xtitle='AC Count',ytitle='N',$
axis_style=1,margin=[0.15,0.15,0.15,0.15])

; Create a new plot coordinate system
newDS = plot([0,100],[0,1],/current, /nodata, $
margin=[0.15,0.15,0.15,0.15], axis_style=0)
axs=axis('Y',location=[100,0],title='Cum. Probability', $
target=newDS, $
color='red',tickdir=0,textpos=1)

Note the /nodata in the PLOT call.

Hope this helps.

Cheers,
Chris
ITTVIS
Re: save axis [message #72045 is a reply to message #72038] Tue, 03 August 2010 11:35 Go to previous message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
one more quirk. th efull plot code I use is

plt=plot(loc,hist,/
histogram,xrange=[0,100],yrange=[0,0.2],color='black',linest yle='solid',thick=2.5,$
xtitle='AC
Count',ytitle='N',title=region_a[i],axis_style=1,margin=[0.1 5,0.15,0.15,0.15])
axs=axis('Y',location=[100,0],title='Cum.
Probability',color='red',tickdir=0,textpos=1)
axs.yrange=[0,1]

As soon as I set the axis range, the title set in plt call moves to
0.2 in the middle of the plot. grrrrr.

H
Re: save axis [message #72046 is a reply to message #72045] Tue, 03 August 2010 11:27 Go to previous message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
Ok, so


axs=axis('Y',location=[100,0],title='Cum.
Probability',color='red',tickdir=0,textpos=1)
axs.yrange=[0,1]



seems to specify the range. But why can't I specify range in the
initial call to axis?

H
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: color plot to file
Next Topic: Re: color plot to file

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

Current Time: Sun Oct 12 06:43:46 PDT 2025

Total time taken to generate the page: 1.12021 seconds