A matplotlib backend based on HTML5 Canvas.
Project description
This provides a web-delivered interactive matplotlib backend using HTML5 technologies including WebSocket and the Canvas element.
Our main goal is to have a backend that is consistent across multiple platforms, has no installation dependencies, is easy and fast to animate, and retains compatibility with current matplotlib usage scenarios.
Installation instructions can be found below or on the project’s Wiki page. The short answer:
easy_install mplh5canvas
Features
Pure Python with no installation dependencies (apart from matplotlib itself)
Requires web browser with Canvas and WebSocket support (Chrome 4+ and Safari 5+ works out of the box, Firefox 4+ and Opera 11+ works after enabling WebSockets in their preferences, but Internet Explorer is not supported)
Designed with animation and interactivity in mind (resizable, zoomable, clickable regions, etc)
Simple plots (e.g. a 2048-point line plot) can be animated at around 60 frames per second
Allows proper remote access to plots
Allows multiple concurrent access to plots
Thumbnail window allows quick cycling between plots on a single page
Screenshot
Requirements
We have tried to keep this module as free of dependencies as possible in order to open up the widest possible installation base. It may, however, be more practical to include some external dependencies in the future. For example, we pull in and modify the excellent pywebsocket code for handling our browser communications. As the standard emerges, it may be better to depend on this directly.
The current base system requirements prior to installation are:
Python 2.5 or newer (2.4 should also be OK, but has not been tested)
Matplotlib 0.99.1.1 or newer
The web browser you use to display the plots must support Canvas and WebSockets (see http://caniuse.com/#feat=websockets for a summary of current WebSocket support). The status quo for the main browsers in May 2011 is:
Chrome 9.0+ works out of the box and is the target browser
Safari 5.0+ works out of the box
Firefox 4.0+ works after unblocking WebSocket support:
Browse to the about:config preferences page and promise to be careful
Type websocket in the filter to find the right option
Double-click on network.websocket.override-security-block to set it to true
Opera 11.0+ works after unblocking WebSocket support:
Browse to the Preference Editor at the opera:config page
Type websocket in the “Quick find” search field to zoom in on the right option (“Enable WebSockets” under User Prefs)
Check the tickbox and click on the Save button
Internet Explorer is not supported
Both Firefox and Opera currently support WebSockets, but block it by default. This is likely to change in the near future, and in the meantime WebSockets remain a simple and powerful way to obtain persistent connections across a wide variety of platforms given the limited available developer resources.
The code now supports both draft-75 and draft-76 WebSockets and so should be reasonably future proof (until they change the standard again).
Netifaces
It is surprisingly difficult to make a good guess of the IP address of a user’s primary network interface across a range of operating systems. The code uses socket.gethostbyname by default, which does a reasonable job but is completely borked if you have VMware installed.
If available it will use the netifaces module which generally does a better job. It is recommended that you install this by running:
easy_install netifaces
Installation
Since this package is available on PyPI the simplest way to install it is to do:
easy_install mplh5canvas
Alternatively, download the latest tarball or check out the source code from Google Code and do:
python setup.py install
It is assumed that you have the proper permissions to install Python packages on your system (if not, you can make use of virtualenv instead).
Testing
We provide a number of example scripts for initial testing. Surprisingly these are found in the examples directory of the source code.
The script names are self-explanatory. The URL of the management server should be printed out by the script, and if a web browser is installed and available a new tab should be opened in your browser. If not, then just copy and paste the management URL into a browser window.
Conformance Testing
To try and reach a level of reasonable conformance we have a crude test suite that will run against a directory of matplotlib examples and produce a web page for side-by-side comparison:
cd tests python test.py -d <matplotlib source tree>/lib/mpl_examples/pylab_examples
This produces output files in the tests/output directory. The file test.html when viewed in a web browser will show the mplh5canvas implementation alongside a PNG and SVG for each file in the target directory.
Be aware that these test results can be pretty massive and may well lead to browser instability. You can run on a restricted set of tests by using a wildcard parameter (see test.py --help).
There is also the option of rendering each canvas on the page to a PNG for easier side-by-side comparison. To do this, run:
python rec.py
once you have a completed test run. At the bottom of the test.html page click the “Connect” button. Then click the “Put Images to Server” button. The rec.py instance should indicate a variety of files being written to disk. Then open the test_rendered.html page which will have a side-by-side column of PNGs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mplh5canvas-0.5.tar.gz
.
File metadata
- Download URL: mplh5canvas-0.5.tar.gz
- Upload date:
- Size: 59.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bffd8423d399426f4c35354323a22f62f7f9d28f30ad07f2556ef2d3b92c6c70 |
|
MD5 | de1a64e81a635d589e85dc33a229e4f7 |
|
BLAKE2b-256 | b10429c45a8d6ad9684ea4d4e8a216fe6a94f2870ee4ae3d66471b57d8f6f0d8 |
File details
Details for the file mplh5canvas-0.5-py2.5.egg
.
File metadata
- Download URL: mplh5canvas-0.5-py2.5.egg
- Upload date:
- Size: 103.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 890f606af24b377d4f9cc3e1d4205b83cab6b1c3f7ee92794dc9bf93f226163c |
|
MD5 | e822d1f6f898757754f80b46bf3368b1 |
|
BLAKE2b-256 | 5317c144f5b96aa0ee8a8e35fd8d479380c9946304e96257c01f6cf99cc68c9f |