Search code examples
rgooglevis

gvisScatterChart - hAxis.title and vAxis.title not appearing on the plot


hAxis.title and vAxis.title options don't seem to set the axis titles for gvisScatterChart in the package googleVis.

plot(gvisScatterChart(data.frame(x = 3, y = 4), options=list(hAxis.title = 'foo')))

"foo" doesn't appear as the horizontal axis title.


Solution

  • You're supposed to pass options to hAxis in a dictionary-looking JSON object format:

    plot(gvisScatterChart(data.frame(x = 3, y = 4), options=list(hAxis="{title:'foo'}")))
    

    See the examples at the bottom of the help page and this under hAxis:

    a JSON object. Default null. An object with members to configure various horizontal axis elements. To specify properties of this object, you can use object literal notation, as shown here:
    {title: 'Hello', titleTextStyle: {color: '#FF0000'}}