Plot going off graph in gvisMotionChart
Asked Answered
C

2

8

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

Chameleon answered 5/2, 2014 at 10:26 Comment(0)
E
5

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!

Expectorate answered 12/2, 2014 at 13:53 Comment(0)
C
0

I just had the same problem w/ a Sankey plot. I resolved it by deleting entries with value==0. However, I just tried to reproduce your example and could not reproduce your bug, so perhaps this has already been solved?

Coagulate answered 10/7, 2014 at 11:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.