Search code examples
rggplot2googlevis

Mapping variable values to colors in gvisLineChart?


I'm looking for the equivalent of:

ggplot(df,aes(x=date,y=var1,**group=col1,colour=col1**))+geom_line() 

in the googleVis package.

Anyone knows how to do this? I only found examples of differently colored lines if they are mapping different columns from the dataframe.

thanks!


Solution

  • @mtoto, I hope my answer here on ggplot2 equivalent of 'factorization or categorization' in googleVis in R can help. Have you taken a look?

    Using roles you can specify specific styles for your data. It involves adding another column with the style detail. So if plotting varx, you need to add the column varx.style where you will set the colors.

    I do not know ggplot well enough to know if this is the exact fit of what you want, but please take a look at my figures and links in that answer.