Getting notified when a ggplot2 plot completes drawing in the device

23 views
Skip to first unread message

David Lewis

unread,
Feb 16, 2018, 1:09:44 PM2/16/18
to ggplot2
I use ggplot2 in a shiny app, and sometimes the number of datapoints means the plot takes a while to appear. I would like to show a notification that advises the user that something is happening and then gets dismissed when the plot appears on screen. I have tried inserting showNotification/removeNotification around the creation of the ggplot object, in the renderPlot() call and elsewhere but they all get dismissed before the plot actually appears. I guess there is rendering going on in the plot device in the background. Is there any way to get a notification that the plot has appeared in the plotting device? Otherwise the temptation for the user is to assume there is a crash or to initiate another plot cycle.

Thanks for any suggestions
David

Brandon Hurr

unread,
Feb 16, 2018, 1:20:34 PM2/16/18
to David Lewis, ggplot2
It's not visual, but how about audio?

https://cran.r-project.org/web/packages/beepr/index.html
> --
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ggplot2+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

David Lewis

unread,
Feb 17, 2018, 4:06:49 AM2/17/18
to ggplot2
Thanks Brandon but it would not help with the problem that the beep() would still be triggered BEFORE the plot appears in the graphics device.
This is the basic scenario pseudocode:

output$plot <- renderPlot({
showNotification("Starting plot", id = "a")
ggplot(data = someBigDataSet, ...) +
geom_boxplot()
# a beep() or removeNotification HERE happens BEFORE the box plot appears - user thinks there is a crash
})

where can I insert code that only gets called when drawing of the plot in the graphics device has ended and the plot actually appears???

Thanks
Reply all
Reply to author
Forward
0 new messages