googleVis 0.2.13: new stepped area chart and improved geo charts

December 23, 2011

(This article was first published on mages' blog, and kindly contributed to R-bloggers)

On 7th December Google published a new version of their Visualisation API. The new version adds a new chart type: Stepped Area Chart and provides improvements to Geo Chart. Now Geo Chart has similar functionality to Geo Map, but while Geo Map requires Flash, Geo Chart doesn’t, as it renders SVG/VML graphics. So it also works on your iOS devices.

Those new features have been added to the googleVis R package in version 0.2.13, which went live on CRAN a few days ago.

The function gvisSteppedAreaChart works very much in the same way as gvisAreaChart. Here is a little example:

df <- data.frame(country=c("US", "GB", "BR"),
val1=c(1,3,4), val2=c(23,12,32))
SteppedArea <- gvisSteppedAreaChart(df, xvar="country",
yvar=c("val1", "val2"),
width=400, height=150))

The interface to gvisGeoChart changed slightly to take into account the new version of Geo Chart by Google. The argument numvar has been renamed to colorvar and a new argument sizevar has been added. This allows you to set the size and colour of the bubbles in displayMode='markers' depending on columns in your data frame. Further, you can set far more options than you could before, in particular you can set not only the region, but also the resolution of your map. Though more granular maps are not available for all countries, for more details see the Google documentation.

Here are two examples, plotting the test data set CityPopularity with a Geo Chart.The first plot shows the popularity of New York, Boston, Miami, Chicago, Los Angeles and Houston on the US map, with the resolution set to 'metros' and region set to 'US'. The Google Map API makes the correct assumption about which cities we mean.

library(googleVis> ## requires googleVis version >= 0.2.13
gcus <- gvisGeoChart(CityPopularity,
locationvar="City", colorvar="Popularity",
region="US", resolution="metros"),

In the second example we set the region to 'US-TX', therefore Google will look for cities with the same names in Texas. And what a surprise, there are cities/towns named Chicago, Los Angeles, Miami, Boston and of course Houston in Texas.

gctx <- gvisGeoChart(CityPopularity, 
locationvar="City", colorvar="Popularity",
region="US-TX", resolution="metros"),

With the new version of the Visualisation API Google introduced also the concept of DataTable Roles. This is an interesting idea, as it allows you to add context to the data, similar to the approach used with annotated time lines. Google classifies the DataTable Roles still experimental, but it is a space to watch and ideas on how this could be translated into R will be much appreciated.

And now the news of the googleVis package since version 0.2.10:

Version 0.2.13 [2011-12-19]


o The list of arguments for gvisGeoChart changed:
- the argument 'numvar' has been renamed to 'colorvar' to
reflect the updated Google API. Additionally gvisGeoChart
gained a new argument 'sizevar'.
o Updated googleVis vignette with a section on using googleVis
output in presentations
o Renamed demo EventListner to EventListener


o Google published a new version of their Visualisation API on 7
December 2011. Some of the new features have been implemented
into googleVis already:
- New stepped area chart function gvisSteppedAreaChart
- gvisGeoChart has a new marker mode, similar to the mode in
gvisGeoMap. See example(gvisGeoChart) for the new

Version 0.2.12 [2011-12-07]

Bug Fixes

o gvisMotionChart didn't display data with special characters,
e.g. spaces, &, %, in column names correctly.
Thanks to Alexander Holcroft for reporting this issue.

Version 0.2.11 [2011-11-16]


o Updated vignette and documentation with instructions on changing
the Flash security settings to display Flash charts locally.
Thanks to Tony Breyal.
o New example to plot weekly data with gvisMotionChart
o Removed local copies of gadget files to reduce package file
size. A local copy of the R script to generate the original gadget
files is still included in inst/gadgets

Version 0.2.10 [2011-09-24]


o Updated section 'Using googleVis output with Google Sites,
Blogger, etc.' vignette

o Updated example for gvisMotionChart, showing how the initial
chart setting can be changed, e.g to display a line chart.

o New example for gvisAnnotatedTimeLine, showing how to shade
areas. Thanks to Mike Silberbauer for providing the initial code.


o New demo WorldBank. It demonstrates how country level data can
be accessed from the World Bank via their API and displayed with a
Motion Chart. Inspired by Google's Public Data Explorer, see

To leave a comment for the author, please follow the link and comment on their blog: mages' blog. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , , ,

Comments are closed.


Mango solutions

RStudio homepage

Zero Inflated Models and Generalized Linear Mixed Models with R

Dommino data lab

Quantide: statistical consulting and training



CRC R books series

Six Sigma Online Training

Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)