Reversing Object Graphics Axis Range [message #27476] |
Thu, 25 October 2001 07:15  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Folks,
I had occasion the other day to require a reverse
object graphics axis (I.e., one that went from 1.2
at the bottom of the axis to 0 on the top. In direct
graphics, I could simply reverse the axis range:
Plot, data, ZRange=[1.2, 0]
You can do the same thing in object graphics. And
the result is an axis with the proper numbers, alright,
but with the annotation oriented upside down and backwards!
It was a tad hard to read. :-)
I figured out a way (eventually) to get what I wanted,
but I ran into all kinds of interesting "features"
in the process. I was going to write my observations
up in an article to save everyone else the excessive
effort, but I got to thinking that *surely* this can't
really be this hard.
So, has anyone managed to do something like this in
a simple and straightforward way that I may have
overlooked?
Cheers,
David
P.S. Let's just take as a working definition of
"simple and straightforward" something that takes
less than 15 lines of code. :-)
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: Reversing Object Graphics Axis Range [message #27529 is a reply to message #27476] |
Sun, 28 October 2001 12:53  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Mark Hadfield (m.hadfield@niwa.cri.nz) writes:
> Steady on, I didn't suggest it, I told you about it. If I suggested
> anything, it was that you keep the axis range positive and use TICKFORMAT to
> fool the user. Perhaps you'd like to mention that alternative on your page.
> (Uh oh I think I just volunteered for something.)
Yeah, I'm *done* with this topic. :-)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: Reversing Object Graphics Axis Range [message #27531 is a reply to message #27476] |
Sun, 28 October 2001 12:36  |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
From: "David Fanning" <david@dfanning.com>
> You can find the explanation (and other recent new
> tips to my web page) here: ...
>
> There is also an example program that you can download
> to see how this works. You can find the example program
> here: ...
Great work, David, I'll have a look at it.
> Note that unlike the RSI example Mark suggested the
> other day...
Steady on, I didn't suggest it, I told you about it. If I suggested
anything, it was that you keep the axis range positive and use TICKFORMAT to
fool the user. Perhaps you'd like to mention that alternative on your page.
(Uh oh I think I just volunteered for something.)
BTW I love this concluding statement on your tips page
"One problem with object graphics is that it can be more difficult than you
wanted it to be to write general programs."
Hear hear. (Though I think you could argue that this is even more difficult
in direct graphics.)
---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield
National Institute for Water and Atmospheric Research
--
Posted from clam.niwa.cri.nz [202.36.29.1]
via Mailgate.ORG Server - http://www.Mailgate.ORG
|
|
|
Re: Reversing Object Graphics Axis Range [message #27533 is a reply to message #27476] |
Sun, 28 October 2001 11:38  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
I wrote the other day,
> So, has anyone managed to reverse an object graphics
> axis in a simple and straightforward way that I may have
> overlooked?
Alas, I got damn few entries in this category. :-(
So, after spending only four solid days researching
the subject I have come up with a method that, while
not exactly straightforward, at least has the advantage
that it can be explained to reasonably intelligent
human beings. At the very least, *I* can understand
it ... sorta. :-)
You can find the explanation (and other recent new
tips to my web page) here:
http://www.dfanning.com/documents/tips.html#NewTips
There is also an example program that you can download
to see how this works. You can find the example program
here:
http://www.dfanning.com/programs/reverse_axes.pro
Note that unlike the RSI example Mark suggested the
other day, these axis titles don't jump all over the
page when the axes are reversed. :-)
One other thing. I've always been mildly annoyed
that the X axis title has appeared closer to its
axis annotation than either the Y axis or the Z axis
titles do. I believe I have discovered the reason for
this, and my method incorporates a "fix" that appears
to correct the problem.
Indeed, you don't have any idea *what* you are going
to learn when you ask one of these simple object
graphics questions. :-)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: Reversing Object Graphics Axis Range [message #27577 is a reply to message #27476] |
Thu, 25 October 2001 22:35  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Mark Hadfield (m.hadfield@niwa.cri.nz) writes:
> Not really. Are you aware that there is an object graphics reverse-axis
> example included with IDL (EX_REVERSE_PLOT)? It was introduced with 5.4. At
> the time I tried it out and noticed various problems, in particular that the
> titles looked wrong. I raised this with Atle @ RSI Tech Support and he sent
> back a cool little GUI routine, which I have taken the liberty of attaching.
> I don't know if it handles every case though and it seems kind of fiddly.
I've spent most of the evening fiddling around with this
little program of Atle's that you sent me. I think I understand
how it works (although not why anyone would want to *do* it
this way), but I've watched that Y title flip-flop around
for an hour now, trying to figure out why it is doing that.
When you reverse the axis, the title jumps out about
10-15 pixels further to the left. When you reverse them
again, it jumps back closer to the axis. It drives a
guy like me batty. :-(
But I think I've figured it out. When the axis is
reversed, the viewport change suddenly throws you
into "negative" space, although it doesn't look that
way to the viewer, since the viewport change
fakes you out. But I think that axis title moves
to accommodate the negative sign that *should* be
on the axis annotation (but isn't, of course).
That's so weird, but I can understand it. Because
it is the same problem I have making my (humph,
more elegant) solution work in a general way. I want
to place the axis title "close to" the annotation.
But how close is that? I can't tell. It depends upon
what numbers are there. But there is no way to tell
how big the numbers are, is there?
I've been thinking about writing a little "nudger"
object that will allow you to "nudge" an axis
title in or out, depending upon what looks best.
Object graphics sure are fun. :-0
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: Reversing Object Graphics Axis Range [message #27589 is a reply to message #27476] |
Thu, 25 October 2001 14:33  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Mark Hadfield (m.hadfield@niwa.cri.nz) writes:
> This is Atle's EX_REVERSE, right? I think he has to do that because he's not
> using [X,Y,Z]COORD_CONV (he's obviously being paying too much attention to
> Randall Frank). So shifting the viewplane rectangle would be necessary for
> any change in axis range.
Randy obviously knows what he is doing, but
I have to admit I usually don't have a clue
how his code works. It's really as though it
were written in some ancient Sumerian script
as far as I'm concerned.
But if he thinks run-of-the-mill IDL programmers
are going to shift viewplane rectangles around
in order to get axis titles oriented correctly,
I think he has missed his target audience entirely.
Hell, I've been looking at it for an hour and a half
now and I *still* can't explain it. :-(
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
|
Re: Reversing Object Graphics Axis Range [message #27591 is a reply to message #27476] |
Thu, 25 October 2001 14:05  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Mark Hadfield (m.hadfield@niwa.cri.nz) writes:
> Not really. Are you aware that there is an object graphics reverse-axis
> example included with IDL (EX_REVERSE_PLOT)? It was introduced with 5.4. At
> the time I tried it out and noticed various problems, in particular that the
> titles looked wrong.
By changing the viewplane rectangle!? You have got
to be kidding me. :-)
No thanks. I have a solution that is better than
the one I came up with the other day, but it still
requires jumping through too many hoops. At the moment
it involves creating my own axis title instead of
allowing IDL to do it. Although a pain in the neck,
it does have the advantage that I can place the title
where I want it, instead of the arbitrary (and unequal)
distance from the axes that the IDL algorithm uses.
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
|
Re: Reversing Object Graphics Axis Range [message #27595 is a reply to message #27476] |
Thu, 25 October 2001 12:49  |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
From: "David Fanning" <david@dfanning.com>
> I had occasion the other day to require a reverse
> object graphics axis (Ie., one that went from 1.2
> at the bottom of the axis to 0 on the top....
>
> I figured out a way (eventually) to get what I wanted,
> but I ran into all kinds of interesting "features"
> in the process. I was going to write my observations
> up in an article to save everyone else the excessive
> effort, but I got to thinking that *surely* this can't
> really be this hard.
>
> So, has anyone managed to do something like this in
> a simple and straightforward way that I may have
> overlooked?
Not really. Are you aware that there is an object graphics reverse-axis
example included with IDL (EX_REVERSE_PLOT)? It was introduced with 5.4. At
the time I tried it out and noticed various problems, in particular that the
titles looked wrong. I raised this with Atle @ RSI Tech Support and he sent
back a cool little GUI routine, which I have taken the liberty of attaching.
I don't know if it handles every case though and it seems kind of fiddly.
So I have gone back to my original method of reversing object-graphics axes:
keep the data range positive and use TICKFORMAT to make it *look* reversed.
For example if I have an array "depth" representing positive distance below
the ocean surface and I want to plot it against the Y axis, I use
z = - depth
xaxis = obj_new('IDLgrAxis', 1, RANGE=[min(z),max(z)] $
, TITLE='Depth (m)', TICKFORMAT='mgh_tf_negative')
where MGH_TF_NEGATIVE is here
http://katipo.niwa.cri.nz/~hadfield/gust/software/idl/mgh_tf _negative.pro
and there's also a more general linear-scaling routine here
http://katipo.niwa.cri.nz/~hadfield/gust/software/idl/mgh_tf _linear.pro
---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield
National Institute for Water and Atmospheric Research
--
Posted from clam.niwa.cri.nz [202.36.29.1]
via Mailgate.ORG Server - http://www.Mailgate.ORG
|
|
|
Re: Reversing Object Graphics Axis Range [message #27618 is a reply to message #27476] |
Thu, 25 October 2001 07:54  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning (david@dfanning.com) writes:
> I had occasion the other day to require a reverse
> object graphics axis (I.e., one that went from 1.2
> at the bottom of the axis to 0 on the top.
> [snip]
> So, has anyone managed to do something like this in
> a simple and straightforward way that I may have
> overlooked?
I've actually just solved *part* of my problem.
I can now get the axis tick annotation to appear
correctly if I set the TextUpDir keyword for the
axis:
zAxis = Obj_New("IDLgrAxis", 2, Color=[0,255,0], Ticklen=0.1, $
Minor=4, Title=ztitleObj, Range=Reverse(zrange), $
TextUpDir=[0, 0, -1])
Now it is just the axis TITLE that is reversed.
I've tried setting the UpDir keyword on the text
object that I use for the title, but properties you
set for text objects don't seem to have
any effect when the text object is part of an
axis unit. Has anyone else noticed this?
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|