How to set axis options in googleVis

Setting axis options in googleVis charts can be a bit tricky. Here I present two examples where I set several options to customise the layout of a line and combo chart with two axes. The parameters have to be set in line with the Google Chart Tools API, which uses a JavaScript syntax. In googleVis chart options are set via a list in the options argument. Some of the list items can be a bit more complex, often wrapped in {} brackets, e.g. for various formatting options or in [] brackets, if there are multiple series to consider. Within those brackets sub-options are set via argument : value, using the : character for assignments.

There are many other options as part of the Google Chart Tools API, which are not supported by googleVis yet, such as columns roles, controls and dashboards, etc. Please get in touch if you have ideas in this regard and/or would like to collaborate.

In my first example I display two series of dummy data in a line chart with two axes. The left hand scale is in percentages and the right hand scale in amounts. Note in the code below how I set the various parameters and the placements of the different kinds of brackets.

In my second example I plot the data in a combo chart, with the amounts in millions to be displayed in bars and the percentage values as a line. Again, I set the various parameters in the options argument. For more details see the help pages and examples of gvisComboChart and other googleVis charts. Note that the options do vary from chart type to chart type, particularly for a motion chart.

I should add that date values in the x-axis of line, bar, combo and other core charts were introduced with googleVis version 0.4.2, published about 3 weeks ago.

Session Info

R version 3.0.0 (2013-04-03)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

[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.4.2

loaded via a namespace (and not attached):
[1] RJSONIO_1.0-3 tools_3.0.0 


For attribution, please cite this work as:

Markus Gesmann (Apr 09, 2013) How to set axis options in googleVis. Retrieved from

BibTeX citation:

@misc{ 2013-how-to-set-axis-options-in-googlevis,
 author = { Markus Gesmann },
 title = { How to set axis options in googleVis },
 url = { },
 year = { 2013 }
 updated = { Apr 09, 2013 }