[R] Adding Year-Month-Day to X axis
Jim Lemon
drj|m|emon @end|ng |rom gm@||@com
Sun May 6 01:05:48 CEST 2018
Hi Greg,
The only reason I included the staxlab function in the plotrix library
was to fit all the dates onto the axis. If you want to try it:
install.packages("plotrix")
Jim
On Sun, May 6, 2018 at 9:02 AM, Gregory Coats <gregcoats using me.com> wrote:
> Jim, Thanks for responding!
> I am using the official R 3.5.0 for Mac OS X.
> This apparently does not include library (plotrix)
>
> library(plotrix)
> Error in library(plotrix) : there is no package called ‘plotrix’
>
> Greg
>
> On May 5, 2018, at 6:50 PM, Jim Lemon <drjimlemon using gmail.com> wrote:
>
> Hi Greg,
> What you are getting there is a factor, interpreted as a 1:n sequence
> based on the sort order of your "dates". Here's a way to get dates on
> your x-axis in the format you want:
>
> x_yyyymmdd<-as.Date(c("2018-04-25","2018-04-26","2018-04-27",
> "2018-04-28","2018-04-29","2018-04-30","2018-05-01","2018-05-02",
> "2018-05-03","2018-05-04","2018-05-05"),format="%Y-%m-%d")
> plot(x_yyyymmdd, y_duration, type="l",xaxt="n")
> library(plotrix)
> staxlab(1,at=x_yyyymmdd,labels=format(x_yyyymmdd,"%Y-%m-%d"))
>
> Jim
>
>
More information about the R-help
mailing list