Showing posts with label options. Show all posts
Showing posts with label options. Show all posts
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
Customising Lines
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
googleVis 0.5.1 released on CRAN
GoogleVis 0.5.1 was released on CRAN yesterday.
New Features
- New functions
gvisSankey, gvisAnnotationChart, gvisHistogram,and
gvisCalendargvisTimelineto support the new Google charts of the same names (without 'gvis'). - New demo Trendlines showing how trend-lines can be added to Scatter-, Bar-, Column-, and Line Charts.
- New demo Roles showing how different column roles can be used in core charts to highlight data.
- New vignettes written in R Markdown showcasing googleVis examples and how the package works with knitr.
Changes
- The help files of gvis charts no longer show all their options, instead a link to the online Google API documentation is given.
- Updated googleVis demo
- All googleVis output will be displayed in your default browser. In previous versions of googleVis output could also be viewed in the preview pane of RStudio. This feature is no longer available with the current version of RStudio, but is likely to be introduced again with the release of RStudio version 0.99 or higher.
Setting axes limits with googleVis
I posted about the various googleVis axis options for base charts, such as line, bar and area charts earlier, but I somehow forgot to mention how to set the axes limits.
Unfortunately, there are no arguments such as
Here is a minimal example, setting the y-axis limits from 0 to 10:
With more than one variable to plot I can use the
Unfortunately, there are no arguments such as
ylim and xlim. Instead, the Google Charts axes options are set via hAxes and vAxes, with h and v indicating the horizontal and vertical axis. More precisely, I have to set viewWindowMode : 'explicit' and set the viewWindow to the desired min and max values. Additionally, I have to wrap all of this in [{}] brackets as those settings are sub-options of h/vAxes. There are also options minValue and maxValue, but they only allow you to extend the axes ranges.Here is a minimal example, setting the y-axis limits from 0 to 10:
With more than one variable to plot I can use the
series argument to decide which variables I want on the left and right axes and set the viewWindow accordingly. Again, here is a minimal example:Session Info
sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.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.4.3
loaded via a namespace (and not attached):
[1] RJSONIO_1.0-3
googleVis 0.3.2 is released: Better integration with knitr
After last week's kerfuffle I hope the roll out of googleVis version 0.3.2 will be smooth. To test the water I release this version into the wild here and if it doesn't get shot down in the next days, then I shall try to upload it to CRAN. I am mindful of the CRAN policy, so please get in touch or add comments below if you find any show stoppers.
Now this doesn't sound too exciting but it can be tremendously helpful when you write Markdown files for
So what's new in googleVis 0.3.2?
The default behaviour of the functionsprint.gvis and plot.gvis can be set via options(). Now this doesn't sound too exciting but it can be tremendously helpful when you write Markdown files for
knitr. Here is why:UK house prices visualised with googleVis-0.2.16

A new version of googleVis has been released on CRAN and the project site. Version 0.2.16 adds the functionality to plot quarterly and monthly data as a motion chart.
To illustrate the new feature I looked for a quarterly data set and stumbled across the quarterly UK house price data published by Nationwide, a building society. The data is available in a spread sheet format and presents the average house prices and indexed to 100 in Q1 1993 by region in the UK from Q4 1973 to Q1 2012. Unfortunately the data is formated for human eyes rather than for computers, see the screen shot below.
![]() |
| Screen shot of Nationwide's UK house price data in Excel |
install.packages("XLConnect", type="source")).
5 Jun 2012
07:53
googleVis
,
Motion Chart
,
Nationwide
,
News
,
options
,
R
,
Soapbox
,
UK house prices
Setting the initial view of a motion chart in R
Following on from my article about accessing and plotting World Bank data with R I want to talk about how to change the initial view of a motion chart.
Over the last couple of weeks I have been asked a view times how to do this. For instance Stephen O'Grady wanted to create a motion chart, which shows initially a line chart, rather than a bubble chart.
Changing the initial settings of a motion chart is actually quite easy, if you know how to. The trick is to use the
As a case study I will use the World Bank data set and try to do some homework given by Duncan Temple Lang in his course on introduction to statistical computing course. Duncan asked his students to query the World Bank data base to create a line chart, which would show the number of internet users per 1000 in Africa over time. Further, he would like to see a legend next to the chart to identify which country is which and tooltips for each curve to identify the country.
A motion chart, displayed as a line chart, would do the trick.
Okay, getting the data is easy, thanks to the WDI package, or via a direct download, and so it is to create a motion chart with bubbles. Interactively I can change the bubble chart into a line chart, I can select some countries and change the y-axis to log-scale. However, when I reload the page I am back to square one: a bubble chart. So the idea is to pass the changed chart settings on to the initial plot. I find those settings, of the current view, as a string in the advanced tab of the settings window. I click on the wrench symbol in the bottom right hand corner of a motion chart to access this window.
Next I copy this string and paste it into the
Here is an example, where I pre-selected Sierra Leone and Seychelles (countries with the lowest and highest number of internet users) together with Africa, North Africa and Sub-Saharan Africa (all income levels). You find the R code below to replicate the plot.
What does the data tell you? Play around with the graph, e.g. change it to a column graph, deselect all countries and change the y-axes to linear again, and hit the play button. How could we improve the plot?
Over the last couple of weeks I have been asked a view times how to do this. For instance Stephen O'Grady wanted to create a motion chart, which shows initially a line chart, rather than a bubble chart.
Changing the initial settings of a motion chart is actually quite easy, if you know how to. The trick is to use the
state argument in the list of options of gvisMotionChart.As a case study I will use the World Bank data set and try to do some homework given by Duncan Temple Lang in his course on introduction to statistical computing course. Duncan asked his students to query the World Bank data base to create a line chart, which would show the number of internet users per 1000 in Africa over time. Further, he would like to see a legend next to the chart to identify which country is which and tooltips for each curve to identify the country.
A motion chart, displayed as a line chart, would do the trick.
Okay, getting the data is easy, thanks to the WDI package, or via a direct download, and so it is to create a motion chart with bubbles. Interactively I can change the bubble chart into a line chart, I can select some countries and change the y-axis to log-scale. However, when I reload the page I am back to square one: a bubble chart. So the idea is to pass the changed chart settings on to the initial plot. I find those settings, of the current view, as a string in the advanced tab of the settings window. I click on the wrench symbol in the bottom right hand corner of a motion chart to access this window.
![]() |
| Screen shot the settings window of a motion chart |
Next I copy this string and paste it into the
state argument of the options list. Note the line break at the beginning and at the end of the state string in the example. Alternatively I can add \n to both side of the state string. Here is an example, where I pre-selected Sierra Leone and Seychelles (countries with the lowest and highest number of internet users) together with Africa, North Africa and Sub-Saharan Africa (all income levels). You find the R code below to replicate the plot.
What does the data tell you? Play around with the graph, e.g. change it to a column graph, deselect all countries and change the y-axes to linear again, and hit the play button. How could we improve the plot?
30 Sept 2011
08:00
googleVis
,
initial view
,
Motion Chart
,
options
,
R
,
RJSONIO
,
Tutorials
,
WDI
,
World Bank



