Skip to content

Origin of coordinate system

4 messages · Richard Müller, S Ellison, Ben Tupper

#
Dear R-community,

In graphical representations of findings concerning bodies of standing
water (lakes e.g.) in x-y-plots you often make use of a somewhat
different definition of coordinates in a cartesian system:
the origin is top-left, the x-axis (depth of the water body) from top
to bottom and the f(x)-axis from left to right, so you can project the
graphical representation of data in your imagination into the lake.

I wasn't able to find out if this is possible in R-plots of x-y-data.
I can treat the values, which are the x-values  as y-values and vice
versa. In simple plots that gives what I want (with the direction of
the vertical axis from top to down with e.g. ylim = c(60,0). But I am
not content with this. y is f(x) and not the other way round! I think,
when I start with error bars or similar, I will get in trouble.
Therefore my simple question: can I define a coordinate system with
(0,0) in the upper left and the x- and y-axis as I described?

Thanks for your answers - Richard
#
See ?par etc

Setting ylim  sets the bottom and top of the plot respectively, so
plot(1:10, ylim=c(11,0), xlim=c(0,11), ylab='depth')

has 0,0 at top left and an inverted y-axis.

S Ellison
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
#
Thank you for your answer. That's the workaround I use - but that's
not what I intended: the resulting graph looks correct. I used this
approach a hundred times. But the ugly thing remains: the x-values
(independent variables) are treated as y-values, and the y-values
(dependent variables, f(x)) as if they were x-values.But what if I
have several f(x) values for one x-value, and want to create an error
bar or similar? Therefore my question: How can I plot x-values from
top to bottom an y-values from left to right _without_ "masquerading"
them as y resp. x?

Richard

2012/8/23 S Ellison <S.Ellison at lgcgroup.com>:

  
    
#
Hello,
On Aug 23, 2012, at 6:08 AM, Richard M?ller wrote:

            
I think I know what you mean. I suppose that you have already set up a suite of wrapper functions around base graphics for your convenience?  That's the direction I would go, but it sounds you may have done so already.  Like the following?

myDepthPlot <- function(depth, value, value2, ylim = rev(range(depth)), ...) 
  plot(value, depth, ylim = ylim, ...)
  if (!missing(value2)) myDepthPoints(depth, value2, ...)
}

myDepthPoints <- function(depth, value, ...) { points(value, depth, ...) }

Also, you may want to look into Dan Kelley's most excellent OCE package: http://dankelley.github.com/oce/

Neither of the above reconfigures the coordinate system, but they allow the user to access functionality as if it were.

Cheers,
Ben
Ben Tupper
Bigelow Laboratory for Ocean Sciences
180 McKown Point Rd. P.O. Box 475
West Boothbay Harbor, Maine   04575-0475 
http://www.bigelow.org