0

I have googled around for hours and tried a bunch of things to fix my axis problems, but nothing works out.

  1. I need to reverse the labels of the y-axis. The lower the number the better. So in case of the screenshot 350000 should be at the bottom.

  2. The labels of the x-axis are kind of weird. Instead of "27.06.14" the plot shows "2014.50". I tried to change the date format of the data set from "27.06.14" to "27 June 2014" or to "6/27/14" and more but the result stays the same.

I already found several solutions for 1. (e.g. ylim = rev()) and 2., but in my case the plots are printed within a shiny app and maybe this is the problem. If I use the solutions I found the app directly crashes. All plots are generated through the "forecast" package. You can check the whole code of the shiny app here: https://github.com/mhnierhoff/FMWT

Thanks in advance.

EDIT:

@smci

Maybe I wasn't that clear. The app works perfectly, when I don't try to change the axis labels.

> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)

locale:
[1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] lubridate_1.3.3      markdown_0.7.4       rmarkdown_0.3.3      knitr_1.8           
[5] forecast_5.6         timeDate_3011.99     zoo_1.7-11           shinyapps_0.3.63    
[9] shinyIncubator_0.2.1 shiny_0.10.2.1      

loaded via a namespace (and not attached):
[1] colorspace_1.2-4 digest_0.6.6     evaluate_0.5.5   formatR_1.0      fracdiff_1.4-2  
[6] grid_3.1.2       htmltools_0.2.6  httpuv_1.3.2     lattice_0.20-29  memoise_0.2.1   
[11] mime_0.2         nnet_7.3-8       parallel_3.1.2   plyr_1.8.1       quadprog_1.5-5  
[16] R6_2.0.1         Rcpp_0.11.3      RJSONIO_1.3-0    stringr_0.6.2    tools_3.1.2     
[21] tseries_0.10-32  xtable_1.7-4

@David

Thanks. When I try this solution I get the following error:

Error in date [1]: object of type 'closure' is not indexable (translated from German)

You can find the data set here: https://github.com/mhnierhoff/FMWT/blob/master/dataset/Historical_Traffic.csv

EDIT 2:

Thanks to David adding this to the plot function:

plotInput <- function() {
            plot(forecast(getModel(), h=input$ahead),flty = 3, axes = FALSE)
            a <- seq(as.Date(aTR$Date, format = "%d.%m.%y")[1] + 1, 
                     by = "months", length = length(date) + 11)
            axis(1, at = as.numeric(a)/365.3 + 1970, 
                 labels = format(a, format = "%d/%m/%Y"), cex.axis = 0.9)
            axis(2, cex.axis = 0.9, ylog = T)
    }

results in good looking date format.

Finally the x-axis looks great.

Still open: to reverse the y-axis.

MHN
  • 230
  • 2
  • 8
  • 1
    **Post us just the relevant code snippet here**. With random seeded data is fine. – smci Dec 30 '14 at 21:27
  • *"I already found several solutions for 1. (e.g. ylim = rev()) and 2., but in my case the plots are printed within a shiny app and maybe this is the problem. **If I use the solutions I found the app directly crashes.**"* Well which problem do you want us to solve, 2. rather than 1.? Debug your Shiny app? Unless you can reduce the Shiny crash to a small testcase, this isn't a clear question ("Debug my app crashing") and likely to be closed for vagueness. – smci Dec 30 '14 at 21:29
  • *"If I use the solutions I found the app directly crashes."* Please narrow the crash down. Also, it helps if you tell us what OS version and R version you're on. – smci Dec 30 '14 at 21:31
  • Does [this](http://stackoverflow.com/questions/26625549/r-forecasting-with-as-posixlt-ct/26626113#26626113) helps? – David Arenburg Dec 30 '14 at 21:53
  • Thanks @smci and David Arenburg - I have edited my question. – MHN Dec 30 '14 at 22:14
  • Please provide a sample of your data set. – David Arenburg Dec 30 '14 at 22:17
  • @DavidArenburg You can check the whole data set here: https://github.com/mhnierhoff/FMWT/blob/master/dataset/Historical_Traffic.csv – MHN Dec 30 '14 at 22:29
  • You have a different format in your `Date` column than in the linked question. Try `as.Date(Date, format = "%d.%m.%y")[1]` instead of `as.Date(date[1])`. The rest of the code should remain the same – David Arenburg Dec 30 '14 at 23:14
  • Thanks @DavidArenburg this helped a lot. But there is still something wrong, please see my last edit. Thanks very much. – MHN Dec 31 '14 at 11:58

0 Answers0