Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plot going off graph in gvisMotionChart

I have created a plot in R using googleVis, specifically gvisMotionChart, plotting a number of variables.

I am primarily using the line graph and it is all good when I view the graph with all variables, however when I select some of the individual variables it zooms in sunch that some of the plot for this variable is no longer on the graph. I know it should zoom in just to view this variable and can exclude other variables (which is a good feature) but it zooms in too much so that the variable I am after is not entirely on the graph.

This doesn't happen with all variables, and I can get around it by also selecting other variables either side of the one which I want to view, but it would be good if I could fix this. Has anyone come across a similar problem before and know a way around it?

Thanks in advance

EDIT: I have an example of this using the data Batting from the Lahman package. (I know nothing about basaeball so the analysis probably doesn't make sense, in fact looking at the results it almost certainly doesn't but it displays my point). If you run the following code:

library(Lahman)
recent <- subset(Batting, yearID > 2000)
homeruns <- aggregate(HR ~ stint + yearID, data = recent, FUN = sum)
avgHR <- mean(homeruns$HR)
homeruns$HR <- homeruns$HR - avgHR
m <- gvisMotionChart(data = homeruns, idvar = "stint", timevar = "yearID")
plot(m)

Then select the line graph, then subset on number 2, the top part of the graph is cut off

like image 661
user1165199 Avatar asked Feb 05 '14 10:02

user1165199


1 Answers

It seems to be Google's bug. I could even reproduce this same error in their "Visualization Playground" (https://code.google.com/apis/ajax/playground/?type=visualization#motion_chart) making part of the data negative.

I've already reported the issue as a bug: https://code.google.com/p/google-visualization-api-issues/issues/detail?id=1479

Might the force be with them!

like image 85
Baumann Avatar answered Oct 08 '22 19:10

Baumann