[R] x-axis plot problem
David Winsemius
dwinsemius at comcast.net
Sun Feb 7 22:00:09 CET 2010
On Feb 7, 2010, at 3:22 PM, abotaha wrote:
>
> Hi all,
> I tried to have plot of many vector in one plot and i have got a
> nice plot
> but i have problem with x-axis. I want to have month and year
> only(Jul.07
> means July 2007) in x-axis without appearing other number behaind it.
I'm going to assume that you did not want that period between the Mon
and Yr since you did not include it in your label strings.
>
> I would appercit any help.
>
> The R code:
>
> F<-c(7.49,6.91,6.78,6.99,7.44,7.42)
> M<-c(4.81,4.51,5.21,4.65,4.75,3.86)
> P<-c(7.49,15.03,15.19,15.32,15.42,15.45)
> B<-c(16.24,15.87,12.94,11.82,10.86,9.61)
>
> time<-c("Jul/07","Aug/07","Sep/07","Oct/07","Nov/07","Dec/07")
> model<-data.frame(F,M,P,B)
> row.names(model)<-c("Jul07","Aug07","Sep07","Oct07","Nov07","Dec007")
> model
>
> par(mgp=c(2, 1, 0),bty="o" )
> matplot(model, pch = c(1,22,17,16), type = "o",lty=c(2,2,2,5), col
> =c("gray10"," gray10","gray10","gray10"),xlab="Month-
> Year",ylab="Zinth",
> xaxs = "i", yaxs = "i",main="Model Output")
# Change the xaxs="i" to xaxt="n" to suppress the numbers 1:6 from
being stuck under the labels you later lay down with the axis command.
> legend("topleft", legend = c("F", "M","P","B"),text.width =
> strwidth("1,000,000,"),pch=c(1,22,17,16),col =c("gray10","
> gray10","gray10","gray10"),lty=c(2,2,2,5), xjust = 1, yjust = 1,
> bty="n",
> cex=0.8, ncol=2)
> axis(1, 1:6, row.names(model))
> --
> View this message in context: http://n4.nabble.com/x-axis-plot-problem-tp1472286p1472286.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.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list