[R] dynamic plots

Greg Snow 538280 at gmail.com
Wed Oct 17 19:43:51 CEST 2012

It should be able to be done.

You would first need the data and be able to create the static version
of the plot.  Then write a function that will create the static
version of the plot with some way (argument passed in) to add a
highlighted line.

Then it is just a matter of figuring out which line/state/subject is
closest to the current position of the mouse and passing that
information to the above function to recreate the plot.

Look at the HTKidentify and HWidentify functions in the TeachingDemos
package for a couple of approaches to doing this.  Both of those
functions start with a scatterplot, then highlight an label the point
closest to the mouse pointer dynamically like the graph you point to.
The same idea would work, just with the modified parallel lines plot
instead of the scatterplot.

On Mon, Oct 15, 2012 at 9:12 PM, Tom Keller <kellert at ohsu.edu> wrote:
> Greetings,
> The website fivethirtyeight has a great plot.
> http://www.nytimes.com/interactive/2012/10/15/us/politics/swing-history.html
> Can this be done with R or GGobi or GGPlot?
> thanks,
> Tom
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com

More information about the R-help mailing list