[R] drawing an axis using axis command

Greg Snow Greg.Snow at imail.org
Mon Jul 6 21:51:42 CEST 2009


If the structure is your xx variable, then you are creating a plot that goes from 1911 to 2006 (plus a little to either side), then asking the axis function to draw and label an axis from 1 to 11, which is very far off the plotting device to the left.  Try giving the axis function a list of values actually within the range of the data that you plot.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of John Kane
> Sent: Monday, July 06, 2009 1:13 PM
> To: r-help at r-project.org
> Subject: [R] drawing an axis using axis command
> 
> 
> 
> I am clearly doing something extremely stupid here but why is this code
> not writing the axis values for this graph?
> 
> Any suggestions gratefully received.
> 
> 
> structure(list(year = c(1911L, 1921L, 1931L, 1941L, 1951L, 1961L,
> 1971L, 1981L, 1991L, 2001L, 2006L), total = c(7206643L, 8788483L,
> 10376786L, 11506655L, 14009429L, 18238247L, 21568310L, 24083500L,
> 26994045L, 29639030L, 31241030L), non = c(5619682L, 6832747L,
> 8069261L, 9487808L, 11949518L, 15393984L, 18272780L, 20240165L,
> 22427745L, 23991910L, 24788720L), imm = c(1586961L, 1955736L,
> 2307525L, 2018847L, 2059911L, 2844263L, 3295530L, 3843335L, 4342890L,
> 5448480L, 6186950L), nonperm = c(0L, 0L, 0L, 0L, 0L, 0L, 0L,
> 0L, 223410L, 198640L, 265360L)), .Names = c("year", "total",
> "non", "imm", "nonperm"), class = "data.frame", row.names = c(NA,
> -11L))
> 
> plot(myxx[,1],myxx[,3], xaxt="n",
> xlab="Census Years", ylab="Population"
>  pch=16, col=" red")
> axis(3, at=1:11, labels=myxx[,1])
> 
> 
> 
> 
> 
> __________________________________________________________________
> [[elided Yahoo spam]]
> 
> ______________________________________________
> 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