[R] Formatting Y axis.
ilai
keren at math.montana.edu
Fri Feb 10 21:21:38 CET 2012
yaxt='n' in ?par and ?axis are your friends.
# A plot on log scale labeled with original:
plot(x,log(y),yaxt='n')
axis(2,at=pretty(log(y)),labels=round(exp(pretty(log(y)))))
Works for qqnorm and boxplots, as well as other top level fun.
By the way this is a FAQ.
On Fri, Feb 10, 2012 at 9:43 AM, sock.o <mrsockman at gmail.com> wrote:
> I've looked around and I just can't find anything that will work for my
> needs. This is a bit of a 2 part question but pertaining to the same topic
> so bare with me.
>
> The first is with my qq plot. On the Y axis of my qq plot it'll have my
> sample quantities but because my data is log-normal it'll show numbers
> between 0 - 5 (depending on the data). I'd like to know how to get it,
> instead of displaying 0-5 to display actual values so that way when reading
> it I know where my potential problems are. Would just save a lot of time and
> be an easier more understandable read. Here's sample code to plug in and
> see.
>
> x <- rlnorm(400, 2.3, .8)
> y <- rlnorm(400, 3, 1.6)
>
> plot.new()
> q1 <- qqnorm(log1p(y))
> q2 <- qqnorm(log1p(x))
> points( q1, col = "red")
> points( q2, col = "blue")
> abline( qqline(log1p(y), col = "red") )
> abline( qqline(log1p(x), col = "blue") )
> legend( "bottomright", inset = 0.02, title = "Loc_ID", c("Sayincom",
> "Sayout"), fill = c( "red", "blue"), horiz = TRUE)
>
> So what I want is for the y axis. or even secondary y axis if it's lined up
> properly to read the actual values rather than the logged values.
>
> The second part of this is in regards to my boxplots. In order to fit all of
> the data in a readable manner I've been making log = "y". Which is fine, but
> when trying to estimate the difference via notches it's difficult to
> estimate how far it really is based on the axis being logged. You can use
> the same x as above, or y, whichever floats your boat.
>
> boxplot ( x, notch = TRUE, log = "y", boxwex = .50)
>
> Versus
>
> boxplot ( x, notch = TRUE, boxwex = .50)
>
> What I need from this is for the ability to zoom in on a particular
> location. Rather than be forced to look at things in a log format on my y
> axis to just be able to say, ok I have my mean at 25 and my standard
> deviation is 10 so I want to concentrate this boxplot between 5 and 45 to
> view 2 standard deviations. (That whole mean thing and standard deviations
> are arbitrary numbers but the concept remains)
>
> Any help would be much appreciated. If there are particular packages
> required for any suggestions please include their name in your response.
>
> If you need actual imaging of what the actual graphs I'm working with look
> like as opposed to the randomly generated values that I'm supplying then
> just say so and I'll post the actual graphs I'm trying to work with.
>
> Sincerely,
>
> Sock
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Formatting-Y-axis-tp4376843p4376843.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list