ropensci / ozunconf17

Website for 2017 rOpenSci Ozunconf
http://ozunconf17.ropensci.org/
24 stars 6 forks source link

geom_realtime() #26

Open jonocarroll opened 6 years ago

jonocarroll commented 6 years ago

A more focused application of #23 would be to implement what I've played around with here: https://www.youtube.com/watch?v=3mdiCUbgxi0 as a general plotting framework. I floated the idea on Twitter of extending webrockets to be able to actually plot incoming data in realtime. Point R at a streaming source and tell it to graph it.

cc: @milesmcbain

jonocarroll commented 6 years ago

I seem to recall a shiny gauge that responded in (near?) realtime to a non-blocking API call. Maybe to CRAN requests?

jonocarroll commented 6 years ago

I may be thinking of this though https://gallery.shinyapps.io/087-crandash/ which is probably just updating frequently.

MilesMcBain commented 6 years ago

I'm wondering if there is there some neat way we could make this dual use for streaming and for animations of static data ala gganimate. I think that would be a handy tool to have!

MilesMcBain commented 6 years ago

Like maybe we can create a 'source' that is just an emitter of static data at a defined rate?

jonocarroll commented 6 years ago

So, instead of animating some data and viewing the resulting .gif, we could have

data_object %>%
  electric_ketchup(fps = 60, key = frame) %>%
  geom_realtime()

I like it. I'm not sure that it's easier than just passing the data and saying 'loop this', but ideas.

MilesMcBain commented 6 years ago

Yes. And then we have the more sophisticated:

dat_object %>%
  turbo_catfish(fps = 60, 
                key = frame, 
                loop = True,
                tween_frames = 10, 
                tween_cols = c("x", "y"),
                easing = "cubic-in-out" 
  ) %>%
  geom_realtime()
MilesMcBain commented 6 years ago

Or maybe the tweener is a separate function to the emitter. That way you could tween your realtime streams. Granted you'd have to be plotting a frame behind realtime for that to work.

timchurches commented 6 years ago

Real-time display of streaming data in Shiny would be great. We are currently investigating feasibility of capturing high-temporal-resolution waveform data (ECG, pulse oxygenation etc) in ICUs, and a way to display it as it is acquired would be fab.

There's the Plotly real-time stuff, but it's not open-source and it is not stand-alone - it only works via their servers, afaik. https://github.com/plotly/Streaming-Demos

jonocarroll commented 6 years ago

htmlwidgets, which is how I've incorporated p5.js so far, can have a shiny implementation, so this would work in well.

dicook commented 6 years ago

its probably better to think of this as "stat_realtime" and then you would have the full plotting functionality of gems still available

jonocarroll commented 6 years ago

That would be true if there ends up being more than the current level of ggplot2 in there. There is currently 0, despite the name and appearance. I've been deliberately deceptive in making the plot look like that, but it does have some nice familiarity to people, no?

The question of whether or not ggplot2 could be adapted to plot in realtime is an interesting, but separate one. I suspect it's not quite that flexible.

I'm certainly open to ideas as to how to implement this better than p5.js; @dicook; any help/guidance/contribution you're able to provide would be of great benefit.

stefaniebutland commented 6 years ago

@jonocarroll's blog post on this: 2017 rOpenSci ozunconf :: Reflections and the realtime Package https://ropensci.org/blog/2017/11/14/realtime/

bedantaguru commented 5 years ago

Anything happened afterwards. looks like real real-time plot in R.

Any public Github repository yet?

stefaniebutland commented 5 years ago

This was an experimental project developed during a conference. Here's the public repo https://github.com/ropenscilabs/realtime

jonocarroll commented 5 years ago

We got a proof of concept working at the ROpenSci ozunconf, but @kcf-jackson was the one to actually build something that works. He presented it at useR2018. His version was called jsReact (this repo has examples) but was later refactored to rjs.

FYI, none of this is an actual ggplot2 geom - this is using javascript to visualise data faster than a plot can be generated in R, but using R to do the calculating.