HTML5 Matplotlib Backend

Hello,

Our HTML5 based matplotlib backend is now available at:

http://code.google.com/p/mplh5canvas/

There are some basic installation instructions and included examples
to get going. Keep in mind that the weakest link at this stage is
browser support.

We recommend Chrome for the most hassle free experience.

This is very much a beta release and has not seen action outside of
our internal testing, so we expect some teething troubles :slight_smile:

Please let us know what works for you, and what doesn't, and we will
try and fix things as they come up.

Cheers,

Simon and Ludwig

I just tested it and it’s very cool! It works fairly quickly locally. It seems to work for Safari 5 and Chrome beta. Firefox 3.6.3 is a no show. I haven’t tried Opera. What I’m really curious about is what is the latency like over the actual internet, or under higher server loads (given the round tripping). For us, I’d have to try to get it to work for firefox (I think as a cross platform browser, it’s fairly common, especially on linux systems like Fedora, it’s what the user is most likely to have.). Thanks for sharing this!

William

···

On Mon, Jun 21, 2010 at 9:19 AM, Simon Ratcliffe <sratcliffe@…149…> wrote:

Hello,

Our HTML5 based matplotlib backend is now available at:

http://code.google.com/p/mplh5canvas/

There are some basic installation instructions and included examples

to get going. Keep in mind that the weakest link at this stage is

browser support.

We recommend Chrome for the most hassle free experience.

This is very much a beta release and has not seen action outside of

our internal testing, so we expect some teething troubles :slight_smile:

Please let us know what works for you, and what doesn’t, and we will

try and fix things as they come up.

Cheers,

Simon and Ludwig


ThinkGeek and WIRED’s GeekDad team up for the Ultimate

GeekDad Father’s Day Giveaway. ONE MASSIVE PRIZE to the

lucky parental unit. See the prize list and enter to win:

http://p.sf.net/sfu/thinkgeek-promo


Matplotlib-devel mailing list

Matplotlib-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

This looks very exciting. I don't know how to install chrome on my
rhel5 without root access (I didn't find any binary and the source
build fails due to some missing dependencies) and I have FF3.6.6, but
I'll try to download some development binary of FF, so that it works.

Ondrej

···

On Mon, Jun 21, 2010 at 7:51 AM, william ratcliff <william.ratcliff@...149...> wrote:

I just tested it and it's very cool! It works fairly quickly locally. It
seems to work for Safari 5 and Chrome beta. Firefox 3.6.3 is a no show. I
haven't tried Opera. What I'm really curious about is what is the latency
like over the actual internet, or under higher server loads (given the round
tripping). For us, I'd have to try to get it to work for firefox (I think
as a cross platform browser, it's fairly common, especially on linux systems
like Fedora, it's what the user is most likely to have.). Thanks for
sharing this!

William

On Mon, Jun 21, 2010 at 9:19 AM, Simon Ratcliffe <sratcliffe@...149...> > wrote:

Hello,

Our HTML5 based matplotlib backend is now available at:

http://code.google.com/p/mplh5canvas/

There are some basic installation instructions and included examples
to get going. Keep in mind that the weakest link at this stage is
browser support.

We recommend Chrome for the most hassle free experience.

This is very much a beta release and has not seen action outside of
our internal testing, so we expect some teething troubles :slight_smile:

Please let us know what works for you, and what doesn't, and we will
try and fix things as they come up.

The matplotlib version check seems to fail with matplotlib 1.0.0. Would you consider applying the attached patch?

Mike

version_check.diff (493 Bytes)

···

On 06/21/2010 09:19 AM, Simon Ratcliffe wrote:

Hello,

Our HTML5 based matplotlib backend is now available at:

http://code.google.com/p/mplh5canvas/

There are some basic installation instructions and included examples
to get going. Keep in mind that the weakest link at this stage is
browser support.

We recommend Chrome for the most hassle free experience.

This is very much a beta release and has not seen action outside of
our internal testing, so we expect some teething troubles :slight_smile:

Please let us know what works for you, and what doesn't, and we will
try and fix things as they come up.

Cheers,

Simon and Ludwig

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
   
--
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA

I found a CentOS tarball of Chromium here:

http://code.google.com/p/chromium/wiki/LinuxChromiumPackages

Which seems to work just fine on RHEL5. Just untar it and run "chrome-wrapper". You may want to read through the chrome-wrapper script first: it seems to contain some hardcoded paths specific to the packager's machine, so it's not exactly high quality -- but it seems to work well with the HTML5 backend.

Mike

···

On 07/06/2010 07:49 PM, Ondrej Certik wrote:

On Mon, Jun 21, 2010 at 7:51 AM, william ratcliff > <william.ratcliff@...149...> wrote:
   

I just tested it and it's very cool! It works fairly quickly locally. It
seems to work for Safari 5 and Chrome beta. Firefox 3.6.3 is a no show. I
haven't tried Opera. What I'm really curious about is what is the latency
like over the actual internet, or under higher server loads (given the round
tripping). For us, I'd have to try to get it to work for firefox (I think
as a cross platform browser, it's fairly common, especially on linux systems
like Fedora, it's what the user is most likely to have.). Thanks for
sharing this!

William

On Mon, Jun 21, 2010 at 9:19 AM, Simon Ratcliffe<sratcliffe@...149...> >> wrote:
     

Hello,

Our HTML5 based matplotlib backend is now available at:

http://code.google.com/p/mplh5canvas/

There are some basic installation instructions and included examples
to get going. Keep in mind that the weakest link at this stage is
browser support.

We recommend Chrome for the most hassle free experience.

This is very much a beta release and has not seen action outside of
our internal testing, so we expect some teething troubles :slight_smile:

Please let us know what works for you, and what doesn't, and we will
try and fix things as they come up.
       

This looks very exciting. I don't know how to install chrome on my
rhel5 without root access (I didn't find any binary and the source
build fails due to some missing dependencies) and I have FF3.6.6, but
I'll try to download some development binary of FF, so that it works.
   

--
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA

I have checked in your patch, thanks for the suggestion...

matplotlib 1.0.0 seemed such a distant dream a couple of months back,
which led to the simplistic version check :slight_smile:

Cheers,

Simon

···

On Wed, Jul 7, 2010 at 3:36 PM, Michael Droettboom <mdroe@...31...> wrote:

The matplotlib version check seems to fail with matplotlib 1.0.0. Would you
consider applying the attached patch?

Mike

On 06/21/2010 09:19 AM, Simon Ratcliffe wrote:

Hello,

Our HTML5 based matplotlib backend is now available at:

http://code.google.com/p/mplh5canvas/

There are some basic installation instructions and included examples
to get going. Keep in mind that the weakest link at this stage is
browser support.

We recommend Chrome for the most hassle free experience.

This is very much a beta release and has not seen action outside of
our internal testing, so we expect some teething troubles :slight_smile:

Please let us know what works for you, and what doesn't, and we will
try and fix things as they come up.

Cheers,

Simon and Ludwig

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

--
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Finally had some time to play with this in detail. First, it's very cool, and thanks for doing all this work. I noticed a few things:

The path-clipping approach that simply removes negative-valued vertices doesn't always work, particularly if a line segment begins in the negative and ends up in the visible part of the plot, the entire line segment will disappear. Instead, it would make more sense to make use of the clipping algorithm already in matplotlib (and implemented in fast C++) that will actually splice the line segments at the boundary. I've attached a patch for this.

The display at the bottom that says "Cursor at: X, Y" is in pixels, not in data units. It would be great if this could display data units, though being general enough to support custom scales (eg. log) and projections (eg. polar) may be tricky without making a round-trip to the server.

If I resize the plotting area (using either the "+" or "arrows" icon), the area where the mouse cursor can draw a zooming rectangle does not seem to be updated.

Minor point: I seem to get a traceback when "text.usetex" is True.

Thinking more broadly -- how difficult would it be to just use the plotting area part of the display, and not the plot selection and layout buttons along the top? I think a really great use case of this backend would be to embed plots in a web page, and have an interactive plot inline in the document. In that case, the extra layout features may be unnecessary. Also, (and I'm getting a bit out of my depth here as I haven't done a lot of web development), how hard would it be to integrate this inside of a WSGI-based webapp, perhaps a Django app? The standalone server this is nice for demos, but I can see this becoming very useful as part of a larger web application.

Mike

clipping.diff (1.41 KB)

···

On 06/21/2010 09:19 AM, Simon Ratcliffe wrote:

Hello,

Our HTML5 based matplotlib backend is now available at:

http://code.google.com/p/mplh5canvas/

There are some basic installation instructions and included examples
to get going. Keep in mind that the weakest link at this stage is
browser support.

We recommend Chrome for the most hassle free experience.

This is very much a beta release and has not seen action outside of
our internal testing, so we expect some teething troubles :slight_smile:

Please let us know what works for you, and what doesn't, and we will
try and fix things as they come up.

Cheers,

Simon and Ludwig

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
   
--
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA

Hey Mike,

Instead, it would make more sense to make use of the clipping
algorithm already in matplotlib (and implemented in fast C++) that will
actually splice the line segments at the boundary. I've attached a patch
for this.

Good call. Our main clipping issue that still needs to be resolved is
for markers. This is actually a wider topic since our biggest
performance handicap
is drawing plots with large numbers of markers. Unlike, say SVG, there
is no concept of a predefined shape that we can use in the HTML5
canvas element to create a marker once and then simply copy or
reference for later markers. This is something we will hopefully
investigate at some later date.

The display at the bottom that says "Cursor at: X, Y" is in pixels, not in
data units. It would be great if this could display data units, though
being general enough to support custom scales (eg. log) and projections (eg.
polar) may be tricky without making a round-trip to the server.

As you mentioned, the trick is in giving the client some view on how
pixels should map to data values without fetching these for each mouse
movement. For simple cartesian plots this is probably pretty
straightforward. It is something we need to get working for our
internal use so it should get solved at some stage.

If I resize the plotting area (using either the "+" or "arrows" icon), the
area where the mouse cursor can draw a zooming rectangle does not seem to be
updated.

The benefit of external users :slight_smile: This was an old bug that crept back
in. It has been fixed in the latest commit (along with your clipping
patch).

Minor point: I seem to get a traceback when "text.usetex" is True.

Fixed in latest commit so that it warns the user that tex is not
currently supported. Another thing to do for the next release :slight_smile:

Thinking more broadly -- how difficult would it be to just use the plotting
area part of the display, and not the plot selection and layout buttons
along the top? I think a really great use case of this backend would be to
embed plots in a web page, and have an interactive plot inline in the
document. In that case, the extra layout features may be unnecessary.

There is already some sort of selector in place (you can append a
number onto the base URL to select a specific layout). I think we will
extend this to allow
selection of individual plots with/without extra decorators. Then
other pages could embed these URLs directly as iframes that contain
only the canvas and associated javascript
to display the plot.

I imagine this would also be useful in the context of applications like Sage.

Also, (and I'm getting a bit out of my depth here as I haven't done a lot
of web development), how hard would it be to integrate this inside of a
WSGI-based webapp, perhaps a Django app? The standalone server this is nice
for demos, but I can see this becoming very useful as part of a larger web
application.

Certainly possible. I imagine that as the WebSocket standard becomes
more prevalent it will get integrated
into existing frameworks. Once this happens then the framework can
associate a specific WebSocket URL with a request
that gets internally redirected to the running mplh5canvas server,
making the user experience a bit more seamless.

Our internal use is certainly heading along similar lines, with the
plots being integrated into a number of container technologies
including Flex
and basic HTML pages. As these new use cases come along we can
evaluate the architecture and integrate things a bit more seamlessly.

Thanks again for the feedback, although we are quite familiar with mpl
as users, we are pretty inexperienced with the backend side, and it
helps a lot to get input from people who know the code well.

Simon