SciRuby / sciruby

Tools for scientific computation in Ruby
http://gems.sciruby.com
Other
994 stars 80 forks source link

Interactive, 3D plots #9

Closed translunar closed 9 years ago

translunar commented 12 years ago

Rubyvis is based on Protovis, which allows for a certain level of user interaction. Unfortunately, it's not clear how Rubyvis can be interactive in a way that is portable.

Let's say you render an SVG in SciRuby::Plotter. You could build a custom SVG rendering library which might allow elements to be re-sized or moved. But what if you wanted to display that SVG in a web browser? The interactive portion would be lost.

Alternatively, assume you render an SVG and send it to a browser, and then write Javascript to enable interactivity. Same problem as before, but in reverse: now you can't get the interactivity in SciRuby::Plotter, which doesn't understand Javascript. Plus, the user now has to write in Ruby and Javascript, which is annoying.

There is likely no easy solution to this sort of problem, short of finding a way to interpret Ruby in a web browser. But I include it in the issue tracker for either (a) that day when someone really wants a challenge, or (b) a future redesign of plotting.

Relatedly, Protovis has limited 3D capabilities. Perhaps someone can come up with a solution that enables rendering of 3D plots, written in pure Ruby, in a web browser.

lstrzebinczyk commented 12 years ago

There is a ruby wrapper for opengl for 2d games creating. Its called Chingu and i think its perfect. It can create a window with full interaction. Its a good solution for pure ruby.

blahah commented 11 years ago

Why is SciRuby::Plotter not just a webview of some sort? Seems the most rational ground-up way to design a visualisation suite for ruby would be to use D3.js as the basis for rubyvis (as opposed to the now outdated ancestor, protovis), and plotter would basically be a chromium window.

translunar commented 11 years ago

Mostly because @clbustos wrote Rubyvis before there was a D3. If you'd like to contribute a new plotting tool, we'd be thrilled.

blahah commented 11 years ago

Makes sense. Our lab have just agreed to all switch to ruby for some intensive bioinformatics stuff. We'll want to generate interactive visualisations, so I'm going to at the least create a ruby wrapper around D3. I'll offer anything we do for inclusion in SciRuby.

translunar commented 11 years ago

That would be totally outstanding. Let us know if we can do anything to support you.

On Wed, Jan 23, 2013 at 4:59 PM, Richard Smith notifications@github.comwrote:

Makes sense. Our lab have just agreed to all switch to ruby for some intensive bioinformatics stuff. We'll want to generate interactive visualisations, so I'm going to at the least create a ruby wrapper around D3. I'll offer anything we do for inclusion in SciRuby.

— Reply to this email directly or view it on GitHubhttps://github.com/SciRuby/sciruby/issues/9#issuecomment-12627704.

tallakt commented 11 years ago

Hi!. Just an idea. d3.js just runs inside the browser. Combine it with something like zombie.js to emulate the DOM headless, therubyracer to run js inside ruby, and you get the option to generate a svg inside ruby without the need for a web browser. You just need a specialized viewer that supports SVG to view the output.

Tallak

http://zombie.labnotes.org/ https://github.com/cowboyd/therubyracer

2013/1/24 John Woods notifications@github.com

That would be totally outstanding. Let us know if we can do anything to support you.

On Wed, Jan 23, 2013 at 4:59 PM, Richard Smith notifications@github.comwrote:

Makes sense. Our lab have just agreed to all switch to ruby for some intensive bioinformatics stuff. We'll want to generate interactive visualisations, so I'm going to at the least create a ruby wrapper around D3. I'll offer anything we do for inclusion in SciRuby.

— Reply to this email directly or view it on GitHub< https://github.com/SciRuby/sciruby/issues/9#issuecomment-12627704>.

— Reply to this email directly or view it on GitHubhttps://github.com/SciRuby/sciruby/issues/9#issuecomment-12628095.

agarie commented 11 years ago

Awesome, @Blahah. When you have a repo with something for us to experiment on or if you want some feedback, please post about it on our mailing list. Thanks!

audy commented 11 years ago

I've been thinking about this recently as well:

On one hand, you want to be able to do interactive plotting in Ruby. On the other hand, you want to be able to have interactive, portable plots in the browser/PDF (thinking down the road about something like iPython notebook).

My idea was to build a collection of common plot types that can be created in Ruby but are translated to d3.js (it could be as simple as sending JSON to a d3.js template [like @Blahah and @tallakt mentioned]). These could be rendered in a browser live during a session in the REPL or saved for later viewing in a static HTML file.

I dream of nice DSLs:


plot :box_plot, data_frame do
    y :cancer_cells
    x :treatment
    color :label
    title "Look, ma! I cured cancer!"
end

This becomes JSON sent to a d3.js template for a box_plot. A message is sent to a web server instructing the browser to refresh when the plot is updated allowing for interactivity.

If you want to add custom interactivity or change things about the plot type, you would still have to learn JavaScript. However, as Ruby programmers, we should all be good at that already right?

tallakt commented 11 years ago

I think the combination of a simple dsl like above and the option to apply css style/animation of javascripts for more interactive/complex stuff would be mindblowing. Having the option of viewing the results in a browser and PDF is nice, but for my personal workflow it is better to have a window open that gets updated every time I run my script. I would rather not have a server running on my machine in order to do plotting.

2013/1/30 Austin Richardson notifications@github.com

I've been thinking about this recently as well:

On one hand, you want to be able to do interactive plotting in Ruby. On the other hand, you want to be able to have interactive, portable plots in the browser/PDF (thinking down the road about something like iPython notebook).

My idea was to build a collection of common plot types that can be created in Ruby but are translated to d3.js (it could be as simple as sending JSON to a d3.js template [like @Blahah https://github.com/Blahah and @tallakthttps://github.com/tallaktmentioned]). These could be rendered in a browser live during a session in the REPL or saved for later viewing in a static HTML file.

I dream of nice DSLs:

plot :box_plot, data_frame do y :cancer_cells x :treatment color :label title "Look, ma! I cured cancer!"end If you want to add custom interactivity or change things about the plot type, you would still have to learn JavaScript. However, as Ruby programmers, we should all be good at that already right?

— Reply to this email directly or view it on GitHubhttps://github.com/SciRuby/sciruby/issues/9#issuecomment-12872525.

audy commented 11 years ago

You do have a server running on your machine in order to do plotting (it's called X). The browser window could refresh each time the plot changes. Anyway, let's just see who implements what first :)