[IPython-dev] Interactive Matplotlib in the browser

Michael Droettboom mdroe at stsci.edu
Fri Oct 12 15:49:01 EDT 2012

On 10/12/2012 03:40 PM, Jason Grout wrote:
> On 10/12/12 12:04 PM, Michael Droettboom wrote:
>> I found a better way -- recent versions of the websockets API do support
>> binary data.  The magic incantation to put load binary data into an
>> image object is here:
>> https://github.com/binaryjs/binaryjs/blob/master/examples/helloworld/index.html
> My main obstruction was figuring out how to get the image data into the
> canvas (correctly interpreted, etc).  It seems that using putImage
> overwrites all pixels on the canvas, regardless of the transparency
> settings, at least from what I read.

True -- but rather than using putImage, I continued to use drawImage, 
and it works like a charm.  The weird bit is the way to get a special 
url to an in-memory binary object:

         imageObj.src = (window.URL || window.webkitURL).createObjectURL(

(where evt.data is a Blob object).

>> I've created a new github repo for this -- if we're going to collaborate
>> on this before it develops into a real patch against matplotlib and/or
>> ipython and/or sage that should be more convenient than using gists.
>> https://github.com/mdboom/mpl_browser_experiments
> Great.  I may be somewhat offline for a few days, but mid-next week I'll
> be looking at this more for sure.


BTW -- in the latest incantation, I have animation working.


> Thanks,
> Jason
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev

More information about the IPython-dev mailing list