text inversion when inverting axis [message #88655] |
Mon, 26 May 2014 09:39  |
Jahvasc
Messages: 9 Registered: March 2014
|
Junior Member |
|
|
Hi, I'm trying to make a plot with decreasing values in the x-direction. No problem with this. The problem arises when I use "text" function to write down an annotation to the plot window. Here, I give a very simple example:
a=findgen(10)
b=sqrt(a)
pl=plot(a,b,xrange=[9,0])
tx=text(0.1*max(pl.xrange),0.9*max(pl.yrange),'b=sqrt(a)',/d ata)
I get it also inverted! Am I doing something wrong?
Thanks!
|
|
|
Re: text inversion when inverting axis [message #88656 is a reply to message #88655] |
Mon, 26 May 2014 10:08   |
Matthew Argall
Messages: 286 Registered: October 2011
|
Senior Member |
|
|
My impression is that the text function likes to draw from the minimum value towards maximum value when the DATA keyword is being used. To fix this, you can try changing the orientation of the text. This is what worked for me
a=Findgen(10)
b=Sqrt(a)
pl=Plot(a, b, XRANGE=[9,0])
tx=Text(2, 2.5, 'b=sqrt(a)', /DATA, BASELINE=[1,0,0], ORIENTATION=45)
Note that the docs say that BASELINE=[1,0,0] is the default. However, the following two lines have different results (for me, on IDL 8.2).
tx1=Text(2, 2.5, 'b=sqrt(a)', /DATA, ORIENTATION=45, BASELINE=[1,0,0])
tx2=Text(2, 2.5, 'b=sqrt(a)', /DATA, ORIENTATION=45)
|
|
|
|
Re: text inversion when inverting axis [message #88659 is a reply to message #88656] |
Mon, 26 May 2014 10:43  |
Matthew Argall
Messages: 286 Registered: October 2011
|
Senior Member |
|
|
> Note that the docs say that BASELINE=[1,0,0] is the default. However, the following two lines have different results (for me, on IDL 8.2).
>
> tx1=Text(2, 2.5, 'b=sqrt(a)', /DATA, ORIENTATION=45, BASELINE=[1,0,0])
Actually, any orientation between 1 and 89 give me the same results.
Any value of ORIENTATION between 90 and 179 give another fixed orientation
..................................180
..................................181 and 269
..................................270
..................................271 and 359
The following line also gives the results you desire, and should be less dependent on the glitchy behavior
tx=text(2, 2.5, 'b=sqrt(a)', /data, ORIENTATION=180, UPDIR=[0,1,0])
Note again, however, that UPDIR=[0,1,0] should be the default. The following two lines give different results, though
tx1=text(2, 2.5, 'b=sqrt(a)', /data, ORIENTATION=180)
tx2=text(2, 2.5, 'b=sqrt(a)', /data, ORIENTATION=180, UPDIR=[0,1,0])
|
|
|