hi I plot a series of observation data every minutes in a day as the attachment below plot(wnd,type='l',lty=1,col='red',lwd=1,xlab=xxlab,ylab=yylab,ylim=YY) In the figure, the x-axis tickment is the number of data How can I change it fore example 1h 2h 3h 4h and so on ? -- TANG Jie Email: totangjie at gmail.com Tel: 0086-2154896104 Shanghai Typhoon Institute,China
One way is to do it manually plot(..., xaxt = "n") axis(1, at = seq_along(wnd), labels = paste(seq_along(wnd), "h") The other is to give plot x and y vectors. Michael On Wed, Mar 7, 2012 at 10:25 PM, Jie Tang <totangjie at gmail.com> wrote:> hi > ?I plot a series of observation data every minutes in a day as the > attachment below > > plot(wnd,type='l',lty=1,col='red',lwd=1,xlab=xxlab,ylab=yylab,ylim=YY) > In the figure, the x-axis tickment is the number of data ? How can I change > it > fore example 1h 2h 3h 4h and so on ? > > > -- > TANG Jie > Email: totangjie at gmail.com > Tel: 0086-2154896104 > Shanghai Typhoon Institute,China > > ______________________________________________ > 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. >
The R-help list usually strips attachements and did so with yours so we have no data. You can include sample data by using dput and pasting the result into your email. See ?dput for more information. John Kane Kingston ON Canada> -----Original Message----- > From: totangjie at gmail.com > Sent: Thu, 8 Mar 2012 11:25:21 +0800 > To: r-help at r-project.org > Subject: [R] how to modify the tickment of x-axis > > hi > I plot a series of observation data every minutes in a day as the > attachment below > > plot(wnd,type='l',lty=1,col='red',lwd=1,xlab=xxlab,ylab=yylab,ylim=YY) > In the figure, the x-axis tickment is the number of data How can I > change > it > fore example 1h 2h 3h 4h and so on ? > > > -- > TANG Jie > Email: totangjie at gmail.com > Tel: 0086-2154896104 > Shanghai Typhoon Institute,China > ______________________________________________ > 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.____________________________________________________________ FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!
hi I plot a series of observation data every minutes in a day as the attachment below plot(wnd,type='l',lty=1,col='red',lwd=1,xlab=xxlab,ylab=yylab,ylim=YY) In the figure, the x-axis tickment is the number of data How can I change it fore example 1h 2h 3h 4h and so on ? someone has told me that use dput but it seems useless. Can anyone tell me how to use axis or at ?thank you . -- TANG Jie Email: totangjie at gmail.com Tel: 0086-2154896104 Shanghai Typhoon Institute,China -- TANG Jie Email: totangjie at gmail.com Tel: 0086-2154896104 Shanghai Typhoon Institute,China
hi I plot a series of observation data every minutes in a day as the attachment below plot(wnd,type='l',lty=1,col='red',lwd=1,xlab=xxlab,ylab=yylab,ylim=YY) In the figure, the x-axis tickment is the number of data How can I change it fore example 1h 2h 3h 4h and so on ? someone has told me that use dput but it seems useless. Can anyone tell me how to use axis or at ?thank you . --> TANG Jie > Email: totangjie@gmail.com > Tel: 0086-2154896104 > Shanghai Typhoon Institute,China > > > > -- > TANG Jie > Email: totangjie@gmail.com > Tel: 0086-2154896104 > Shanghai Typhoon Institute,China >[[alternative HTML version deleted]]
> I am plotting several lines in one figure by such codes. But it is strange > that > > only this first tickment of x-axis is shown. > > plot(winddata$v1,type='l', > lty=1,col='black',lwd=1,xlab=xxlab,ylab=yylab,ylim=YY, xaxt = "n") > par(new=T) > plot(winddata$v2,type='l', > lty=1,col='blue',lwd=1,xlab=xxlab,ylab=yylab,ylim=YY, xaxt = "n") > > par(new=T) > plot(winddata$v3,type='l', > lty=1,col='red',lwd=1,xlab=xxlab,ylab=yylab,ylim=YY, xaxt = "n") > > par(new=T) > plot(winddata$v4,type='l', > lty=1,col='green',lwd=1,xlab=xxlab,ylab=yylab,ylim=YY, xaxt = "n") > #axis(1, at = seq_along(winddata$v4), labels > paste(seq_along(winddata$v4), "h") > par(new=T) > plot(winddata$v5,type='l', > lty=1,col='grey',lwd=1,xlab=xxlab,ylab=yylab,ylim=YY, xaxt = "n") > > axis(1, at = 1:4, label = paste(1:4, "h", sep = "") )# Happy axis! > > here is some of the dataset by dput >c(12.9, 13, 14.1, 16.2, 16.1, 16.8, 15.8, 15.9, 15.8, 15.6, 15.3, 15, 14.9, 14, 13.3, 14.3, 14.7, 14.3, 12.6, 11.4, 11.7, 12, 11.9, 12.4, 13.3, 13.4, 14.1, 14.1, 13.6, 14.1, 13.8, 14, 14.3, 14.3, 13.8, 13.6, 13.2, 12.2, 12.7, 12.9, 13.2, 12.5, 12.6, 13.6, 13.9, 13.3, 13.6, 13.7, 12.8, 12, 12.7, 12.6, 13.4, 14, 15.3, 14.5, 13.2, 11.2, 11.2, 12.6, 12.8, 12.1, 11.6, 11.8, 11.8, 12.8, 11.8, 11.6, 12, 12.3, 12.7, 12.9, 12.8, 12.8, 12.3, 12.1, 11.7, 11.4, 11.1, 10.7, 11.3, 12.8, 12.7, 12.3, 13.9, 14.8, 13.1, 12.6, 12.4, 12.7, 12.1, 13.7, 13.8, 14.1, 14.1, 14.2, 13.7, 12.9, 11.7, 11.9, 12.5, 12.7, 12.1, 12.5, 12.7, 12.7, 12.6, 13.1, 13.4, 12.3, 11.6, 10.9, 10.8, 10, 9.5, 10.1, 10.4, 10.3, 11.9, 12, 12.1, 12.4, 11.4, 11, 12.9, 13.2, 13.8, 13.9, 13.4, 13.3, 12.8, 12.5, 12.2)> >2012/3/17 R. Michael Weylandt <michael.weylandt@gmail.com>> > Did you look at the example I gave you when you asked this question 10 >> days ago? I'll repeat for completeness >> >> op <- par() >> par(ask = TRUE) >> plot(1:10) # Unhappy axis >> >> plot(1:10, xaxt = "n") >> axis(1, at = 1:10, label = paste(1:10, "h", sep = "")) # Happy axis! >> par(ask = op$ask) >> >> The (good) advice to use dput() was to help us help you. Reread what was >> said. >> >> Michael >> >> On Sat, Mar 17, 2012 at 10:22 AM, Jie Tang <totangjie@gmail.com> wrote: >> > hi >> > I plot a series of observation data every minutes in a day as the >> > attachment below >> > >> > plot(wnd,type='l',lty=1,col='red',lwd=1,xlab=xxlab,ylab=yylab,ylim=YY) >> > In the figure, the x-axis tickment is the number of data How can I >> change >> > it >> > fore example 1h 2h 3h 4h and so on ? >> > someone has told me that use dput but it seems useless. >> > >> > Can anyone tell me how to use axis or at ?thank you . >> > >> > >> > -- >> >> TANG Jie >> >> Email: totangjie@gmail.com >> >> Tel: 0086-2154896104 >> >> Shanghai Typhoon Institute,China >> >> >> >> >> >> >> >> -- >> >> TANG Jie >> >> Email: totangjie@gmail.com >> >> Tel: 0086-2154896104 >> >> Shanghai Typhoon Institute,China >> >> >> > >> > [[alternative HTML version deleted]] >> > >> > ______________________________________________ >> > R-help@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. >> > > > > -- > TANG Jie > Email: totangjie@gmail.com > Tel: 0086-2154896104 > Shanghai Typhoon Institute,China >-- TANG Jie Email: totangjie@gmail.com Tel: 0086-2154896104 Shanghai Typhoon Institute,China [[alternative HTML version deleted]]
dput() is a way to print out your data in a covenient format for others to read it into an R session. It has nothing to do with graphing. You use the command dput(myfile) to output a data object or perhaps dput(head(myfile, 10) to output a subset of your file. Copy and paste into your email and people on the R-help list then can see what your data looks like. It makes solving problems much easier. Here is one from a simple data set I use for experimenting. ( I added the " mat1 <- " to read it into an r matrix. mat1 <- structure(c(1, 1, 6, 1, 1, NA, 1, 2, 3, 4, 5, 6, 3, 5, 3, 6, 4, 0, 2, 4, 6, 8, 10, 12, NA, 9, 9, 8, 9, 8, 1, 2, 3, 4, 5, 6, 12, 42, NA, 45, 32, 54, 13, 15, 17, 19, 21, 23), .Dim = c(6L, 8L), .Dimnames = list(NULL, c("cata", "catb", "doga", "dogb", "rata", "ratb", "bata", "batb"))) John Kane Kingston ON Canada> -----Original Message----- > From: totangjie at gmail.com > Sent: Sat, 17 Mar 2012 22:17:55 +0800 > To: r-help at r-project.org > Subject: [R] Fwd: how to modify the tickment of x-axis > > hi > I plot a series of observation data every minutes in a day as the > attachment below > > plot(wnd,type='l',lty=1,col='red',lwd=1,xlab=xxlab,ylab=yylab,ylim=YY) > In the figure, the x-axis tickment is the number of data How can I > change > it > fore example 1h 2h 3h 4h and so on ? > someone has told me that use dput but it seems useless. > > Can anyone tell me how to use axis or at ?thank you .I believe others have already done this. Good luck ____________________________________________________________ FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!