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]]
Please show the error message. At 12:13 PM -0700 7/6/09, John Kane wrote:>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.-- -------------------------------------- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA 925-423-1062
After your plot command, type par()$usr It will show you that your x axis range is 1907 to 2009. But you tried to put the axis labels at x=1 to 11, which are not within the range of the data. -Don At 12:13 PM -0700 7/6/09, John Kane wrote:>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.-- -------------------------------------- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA 925-423-1062
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.
Of course. I actually tried that but apparently messed it up. My thanks to eveyone. I knew it was something relatively obvious but I was completely blanking out on it. --- On Mon, 7/6/09, Don MacQueen <macq at llnl.gov> wrote:> From: Don MacQueen <macq at llnl.gov> > Subject: Re: [R] drawing an axis using axis command > To: "John Kane" <jrkrideau at yahoo.ca>, r-help at r-project.org > Received: Monday, July 6, 2009, 3:47 PM > After your plot command, type > > ???par()$usr > > It will show you that your x axis range is 1907 to 2009. > But you > tried to put the axis labels at x=1 to 11, which are not > within the > range of the data. > > -Don > > At 12:13 PM -0700 7/6/09, John Kane wrote: > >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. > > > -- > -------------------------------------- > Don MacQueen > Environmental Protection Department > Lawrence Livermore National Laboratory > Livermore, CA, USA > 925-423-1062 > -------------------------------------- >__________________________________________________________________ The new Internet Explorer? 8 - Faster, safer, easier. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/