Dear All, Apologies for this simple question and thanks in advance for any help given. Suppose I wanted to plot 1 million observations and produce the command plot(rnorm(1000000)) The labels of the xaxis are 0, e+00 2 e+05 etc. These are clearly not very attractive (The plots are for a PhD. thesis). I would like the axes to be 0,2,4,6,8,10 with a *10^5 on the right hand side. Is there a simple command for this? Best Wishes Roger
Here is one way to do it with a smaller set of data, but the 'range' is the same:> x <- c(1,1000,1000000) > y <- pretty(range(x)) > y[1] 0e+00 2e+05 4e+05 6e+05 8e+05 1e+06> plot(x,1:3,xaxt='n', xlab="X * 10^5") > axis(1, at=y, labels=y/100000) >On 12/28/05, R.C.GILL@soton.ac.uk <R.C.GILL@soton.ac.uk> wrote:> > > Dear All, > > Apologies for this simple question and thanks in advance for any help > given. > > Suppose I wanted to plot 1 million observations and produce the command > > plot(rnorm(1000000)) > > The labels of the xaxis are 0, e+00 2 e+05 etc. These are clearly not very > attractive (The plots are for a PhD. thesis). > > I would like the axes to be 0,2,4,6,8,10 with a *10^5 on the right hand > side. > > Is there a simple command for this? > > Best Wishes > > Roger > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >-- Jim Holtman Cincinnati, OH +1 513 247 0281 What the problem you are trying to solve? [[alternative HTML version deleted]]
Try this: x <- c(1, 1e6); y <- 0:1 par(mar = c(5, 4, 4, 5) + 0.1) # make room at the right plot(x, y, axes = FALSE) box() axis(2) axis(1, at = 0:5 * 2 * 1e5, labels = 0:5 * 2) mtext(text = expression(phantom(0)%*%10^5), side = 1, line = 1, at = 11.0 * 1e5) Peter Ehlers R.C.GILL at soton.ac.uk wrote:> Dear All, > > Apologies for this simple question and thanks in advance for any help given. > > Suppose I wanted to plot 1 million observations and produce the command > > plot(rnorm(1000000)) > > The labels of the xaxis are 0, e+00 2 e+05 etc. These are clearly not very > attractive (The plots are for a PhD. thesis). > > I would like the axes to be 0,2,4,6,8,10 with a *10^5 on the right hand > side. > > Is there a simple command for this? > > Best Wishes > > Roger > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
On Wed, 2005-12-28 at 20:15 +0000, R.C.GILL at soton.ac.uk wrote:> Dear All, > > Apologies for this simple question and thanks in advance for any help > given. > > Suppose I wanted to plot 1 million observations and produce the > command > > plot(rnorm(1000000)) > > The labels of the xaxis are 0, e+00 2 e+05 etc. These are clearly not > very > attractive (The plots are for a PhD. thesis). > > I would like the axes to be 0,2,4,6,8,10 with a *10^5 on the right > hand > side. > > Is there a simple command for this? > > Best Wishes > > RogerSee ?plotmath for some additional examples and there are some others in the list archives. set.seed(1) x <- rnorm(1000000) # Now do the plot, but leave the x axis blank plot(x, xaxt = "n") # Set the x axis label tick marks x.at <- seq(0, 10, 2) * 10 ^ 5 # Create the expressions for the tick mark labels # Using parse() takes the character vectors from paste() # and converts them to expressions for use in plotmath x.lab <- parse(text = paste(seq(0, 10, 2), "%*% 10^5")) # Now do the axis labels axis(1, at = x.at, labels = x.lab) HTH, Marc Schwartz