Tuesday, 1 April 2014

Calendar charts with googleVis

My little series of posts about the new googleVis charts continues with calendar charts.

Google's calendar charts are still in beta, but they provide already a nice heat map visualisation of calendar year data. The current development version of googleVis supports this new function via gvisCalendar. Here is an example displaying daily stock price data.


For the code below to run you will require the developer version (≥ 0.5.0-4) of googleVis from GitHub and R ≥ 3.0.2.

I suppose the biggest current drawback is that the colours of the cells cannot be defined by the user. However, this should change with future versions of the Google Chart Tools. For more information and installation instructions see the googleVis project site and Google documentation.

Interestingly, the calendar chart looks very similar to the visualisation R. Wicklin and R. Allison from SAS used for the winning poster at the Data Expo 2009. Paul Bleicher created a function in R, based on lattice that creates a very similar output. You may recall David Smith's blog post about this.



Session Info

R version 3.0.3 (2014-03-06)
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] grid stats graphics grDevices utils datasets  methods  
[8] base     

other attached packages:
[1] googleVis_0.5.0-4 chron_2.3-45 lattice_0.20-24  

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

5 comments:

  1. Carlos Ortega2 April 2014 13:51

    Thanks Markus for your excellent job with googleVis.

    Package "openair"[1] (available in CRAN) includes a function to create calendar plots.
    The function is "calendarPlot()".

    Thanks,
    Carlos.

    [1]: http://www.openair-project.org/

    ReplyDelete
  2. Carlos, thanks for your comment. I didn't know about the openair project. Looks very nice. I particularly like the wind example plot.

    ReplyDelete
  3. I get an error when the following line is executed:

    install_github("mages/googleVis")

    The error is:

    Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
    pdflatex is not available
    Calls: -> texi2pdf -> texi2dvi
    Execution halted
    Error: Command failed (1)



    Is pdflatex required? If so, do you have a link for downloading?


    Thanks,
    Bill

    ReplyDelete
  4. Hi Bill, you can get LaTeX from: http://latex-project.org/ftp.html. However, we have released googleVis 0.5.1 on CRAN recently, so you should be able to install the package in the usual way.
    I hope this helps.
    Markus

    ReplyDelete
  5. Markus,


    I just installed the latest version, it works great.


    Hovering the cursor above each date to show the value is a really nice touch. You guys did a great job.




    Thanks,
    Bill

    ReplyDelete