Zoom in/out on a ggplot2 graphic

1,212 views
Skip to first unread message

Martin Lavoie

unread,
Dec 12, 2013, 4:59:25 PM12/12/13
to shiny-...@googlegroups.com
HI All!

I have been looking for a few days for potential examples but I did not find any.

This example (http://timelyportfolio.blogspot.ca/2013/08/ggplot2-meet-d3.html) illustrates really well what I would like to do.

I would like to zoom in/out on a graph (I am usually using ggplot2 with 100,000-200,000 points) but also with a dynamic input for the datasets and x and y variables. Is it possible?

I am also aware of this thread (https://groups.google.com/forum/#!msg/shiny-discuss/rJhy5sUOe1U/-tllnyS1RFAJ) on this great heatmap but I don't know how to implement on graphics like geom_point in ggplot2 and with a dynamic input.

I also tried g3plot (http://glimmer.rstudio.com/alexbbrown/g3plot/#dataSet=airquality,tabSelected=G3Plot) but with large datasets it was very slow and it does not seem to offer a dynamic input for x and y variables.

Any help would be appreciated or if someone could just point me in the right direction would help.
Thank you
Martin

Daniel Chen

unread,
Jan 27, 2015, 12:01:37 PM1/27/15
to shiny-...@googlegroups.com
I've done something similar with my ggplot graph.
Essentially I have sliders that limit the x-axis and y-axis bounds using `scale_y_continuous(limits=isolate(input$SLIDER_NAME)`
the `isoloate` is bound to a submit button


I've added the submit button widget that way the plot doesn't try to re-render and re-plot for every small slider change (helps with the overall responsiveness)

Joe Cheng

unread,
Jan 27, 2015, 12:08:26 PM1/27/15
to Daniel Chen, shiny-...@googlegroups.com
There also (as of a couple of weeks ago) exists an svgPanZoom htmlwidget that is purported to work with ggplot2 and Shiny:

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/87468a03-75b8-450b-80ad-d96a9bf7c576%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Martin Lavoie

unread,
Jan 27, 2015, 12:11:13 PM1/27/15
to shiny-...@googlegroups.com, dch...@gmail.com
I almost forgot about that question.

thanks a lot Daniel and Joe for your help!!

Martin
Reply all
Reply to author
Forward
0 new messages