Customising lines and points with googleVis
At the end of March Google released a new version of the Chart Tools API with new options for point shapes and line brushes. The arguments are called
We published googleVis 0.5.2 on CRAN yesterday with added examples for those new options in
pointShape
and lineDashStyle
and can be set directly via googleVis. We published googleVis 0.5.2 on CRAN yesterday with added examples for those new options in
gvisLineChart
and gvisScatterChart
. Note, these options can be used with most chart types as well, also in combination. Visit the Google documentation for more details.Customising Points
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(googleVis) | |
M <- matrix(nrow=6,ncol=6) | |
M[col(M)==row(M)] <- 1:6 | |
dat <- data.frame(X=1:6, M) | |
plot( | |
gvisScatterChart(dat, | |
options=list(width=500,height=350, | |
title="Customising points", | |
legend="right", | |
pointSize=30, | |
series="{ | |
0: { pointShape: 'circle' }, | |
1: { pointShape: 'triangle' }, | |
2: { pointShape: 'square' }, | |
3: { pointShape: 'diamond' }, | |
4: { pointShape: 'star' }, | |
5: { pointShape: 'polygon' } | |
}"), chartid="Points") | |
) |
Customising Lines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(googleVis) | |
dat=data.frame(label=c("A", "B", "C"), | |
val1=c(10,13,14), | |
val2=c(23,12,32)) | |
plot( | |
gvisLineChart(dat, xvar="label", yvar=c("val1","val2"), | |
options=list(width=500,height=350, | |
title="Customising lines", | |
series="[{color:'green', targetAxisIndex: 0, | |
lineWidth: 1, | |
lineDashStyle: [2,2,20,2,20,2]}, | |
{color: 'blue',targetAxisIndex: 1, | |
lineWidth: 2, | |
lineDashStyle: [4, 1]}]", | |
vAxes="[{title:'val1'}, {title:'val2'}]" | |
), chartid="Dashed") | |
) |
Session Info
R version 3.1.0 (2014-04-10) Platform: x86_64-apple-darwin13.1.0 (64-bit) locale: [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] googleVis_0.5.2 loaded via a namespace (and not attached): [1] RJSONIO_1.0-3 tools_3.1.0