Search code examples
javascriptrrchartsmorris.js

Is there a way to change colors and axis limits in mPlot in rCharts in R?


I am using mPlot function that links morris javascript library with R statistical package. Examples of how to use this function are here: https://github.com/ramnathv/rCharts/tree/master/inst/libraries/morris

Does anyone know how to change this plot's axis limits and colors of lines?


Solution

  • You can change lineColors, ymax and ymin using chart$set.

    For example, using the third example from the link you posted:

    data(economics, package = 'ggplot2')
    dat = transform(economics, date = as.character(date))
    p3 <- mPlot(x = "date", y = list("psavert", "uempmed"), data = dat, type = 'Line',
                pointSize = 0, lineWidth = 1)
    p3$set(xLabelFormat = "#! function (x) { 
           return x.toString(); } 
           !#")
    p3$set(lineColors=c("red","blue"))
    p3$set(ymax=20)
    p3