Re: Reversing an axis with IDLgrAxis [message #14194] |
Tue, 02 February 1999 00:00 |
Peter Connell
Messages: 6 Registered: November 1998
|
Junior Member |
|
|
An update:
Mark Hadfield's solution is a very neat one and he identifies the actual
problem, which is that the Axis object always plots from smaller to larger
in the conventional positive direction. So I think the answer to Wayne
Baggett's suggestion is that there is no way to do that in object graphics.
Mark uses a Property of the Axis object which appears to have a somewhat
different intention to accomplish the desired result, although it requires
that the data and coordinate be manipulated outside of the object's
knowledge, which somewhat defeats the purpose of objects, I guess.
Unfortunately, Mark's solution doesn't work for my exat problem, since I was
trying to reverse a logarithmic axis. Applying Mark's approach produces
readable ticks and title, but now the log-spaced minor ticks are backwards!
Peter Connell wrote in message <795h53$75m$1@lll-winken.llnl.gov>...
> OK, I give. I would like to plot an axis (object graphics) with values
> descending rather than ascending in the normal positive direction. I can do
> this using (XY)COORD_CONV, but when I do, the tick text and axis title are
> reversed as well (mirror image) and I can't figure out how to reverse them
> back to read normally.
> Any help?
>
> Peter Connell
> connell2@llnl.gov
>
>
>
|
|
|
Re: Reversing an axis with IDLgrAxis [message #14196 is a reply to message #14194] |
Tue, 02 February 1999 00:00  |
Wayne Baggett
Messages: 1 Registered: February 1999
|
Junior Member |
|
|
Peter Connell wrote:
>
> OK, I give. I would like to plot an axis (object graphics) with values
> descending rather than ascending in the normal positive direction. I can do
> this using (XY)COORD_CONV, but when I do, the tick text and axis title are
> reversed as well (mirror image) and I can't figure out how to reverse them
> back to read normally.
> Any help?
>
> Peter Connell
> connell2@llnl.gov
I've never done object graphics, but with the basic PLOT function, just specify
the axis range (e.g., !X.RANGE = [xmin,xmax]) with the "minimum" greater than
the "maximum".
Example:
x = findgen(500)/50.
y = 3.5*sin(x)*x
!y.range=[30.,-20.]
plot,x,y
Is there a similar mechanism for object graphics? If so, you might give it a
try.
--
Wayne Baggett x5011
|
|
|
Re: Reversing an axis with IDLgrAxis [message #14204 is a reply to message #14194] |
Tue, 02 February 1999 00:00  |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
> OK, I give. I would like to plot an axis (object graphics) with values
> descending rather than ascending in the normal positive direction. I can do
> this using (XY)COORD_CONV, but when I do, the tick text and axis title are
> reversed as well (mirror image) and I can't figure out how to reverse them
> back to read normally.
Plot against the inverse of the variable and get the labels you want via
the TICKFORMAT property. The TICKFORMAT_NEGATIVE function below
is designed to do this.
----
Mark Hadfield, m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield/
National Institute for Water and Atmospheric Research
PO Box 14-901, Wellington, New Zealand
********************************
;+
; NAME:
; TICKFORMAT_NEGATIVE
;
; PURPOSE:
; This function is designed for use with the TICKFORMAT property of
IDLgrAxis.
; Given a real value, it returns a string representing the inverse of that
value.
;
; CATEGORY:
; Miscellaneous
; Object graphics
;
; CALLING SEQUENCE:
; Result = FUNCTION_NAME(Direction, Index, Value)
;
; INPUTS:
; Direction: Axis direction, required by the TICKFORMAT interface but
ignored.
;
; Index: Axis index, required by the TICKFORMAT interface but
ignored.
;
; Value: The real value to be formatted.
;
; OUTPUTS:
; The function returns a scalar string.
;
; EXPLANATION:
; IDLgrAxis objects always have the values increasing from left to right.
; The axis can be reversed, but then the axis labels are seen from behind!
; So to get an axis with values decreasing from left to right, we have to
; plot the inverse of the variable and reformat the axis labels.
;
; TO DO:
; Allow format control via the DATA keyword.
;
; MODIFICATION HISTORY:
; Mark Hadfield, Jun 1998:
; Written.
;-
function TICKFORMAT_NEGATIVE, Direction, Index, Value
return, (format_axis_values(-Value))[0]
end
|
|
|
Re: Reversing an axis with IDLgrAxis [message #14207 is a reply to message #14194] |
Mon, 01 February 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Mark Hadfield (m.hadfield@niwa.cri.nz) writes in response to
Peter Connell:
>> OK, I give. I would like to plot an axis (object graphics) with values
>> descending rather than ascending in the normal positive direction. I can do
>> this using (XY)COORD_CONV, but when I do, the tick text and axis title are
>> reversed as well (mirror image) and I can't figure out how to reverse them
>> back to read normally.
>
> Plot against the inverse of the variable and get the labels you want via
> the TICKFORMAT property. The TICKFORMAT_NEGATIVE function below
> is designed to do this.
>
> function TICKFORMAT_NEGATIVE, Direction, Index, Value
>
> return, (format_axis_values(-Value))[0]
>
> end
Very nice. But how in the world did you discover the
Format_Axis_Values function!? You're not one of those
people who read through the documentation for fun are
you? :-)
And why would you think a priori that this would work?
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|