Skip to main content

mpld3: A D3 Viewer for Matplotlib

This is an interactive D3js-based viewer which brings matplotlib graphics to the browser. Please visit http://mpld3.github.io for documentation and examples.

You may also see the blog post, or the IPython notebook examples available in the notebooks directory of this repository.

version status downloads build status

About

mpld3 provides a custom stand-alone javascript library built on D3, which parses JSON representations of plots. The mpld3 python module provides a set of routines which parses matplotlib plots (using the mplexporter framework) and outputs the JSON description readable by mpld3.js.

Installation

mpld3 is compatible with python 2.6-2.7 and 3.3-3.4. It requires matplotlib version 2.2.2 and jinja2 version 2.7+.

Optionally, mpld3 can be used with IPython notebook, and requires IPython version 1.x or (preferably) version 2.0+.

This package is based on the mplexporter framework for crawling and exporting matplotlib images. mplexporter is bundled with the source distribution via git submodule.

Within the git source directory, you can download the mplexporter dependency and copy it into the mpld3 source directory using the following command:

$ python setup.py submodule

The submodule command is not necessary if you are installing from a distribution rather than from the git source.

Once the submodule command has been run, you can build the package locally using

$ python setup.py build

or install the package to the standard Python path using:

$ python setup.py install

Or, to install to another location, use

$ python setup.py install --prefix=/path/to/location/

Then make sure your PYTHONPATH environment variable points to this location.

Trying it out

The package is pure python, and very light-weight. You can take a look at the notebooks in the examples directory, or run create_example.py, which will create a set of plots and launch a browser window showing interactive views of these plots.

For a more comprehensive set of examples, see the IPython notebook examples available in the notebooks directory.

Test Plots

To explore the comparison between D3 renderings and matplotlib renderings for various plot types, run the script visualize_tests.py. This will generate an HTML page with the D3 renderings beside corresponding matplotlib renderings.

Features

Many of the core features of matplotlib are already supported. And additionally there is some extra interactivity provided via the plugin framework. The following is a non-exhausive list of features that are yet to be supported:

  • tick specification & formatting
  • some legend features
  • blended transforms, such as those required by axvlines and axhlines
  • twin axes (i.e. multiple scales on one plot) tied together

If any of these look like something you'd like to tackle, feel free to submit a pull request!

Release files for mpld3 0.5.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mpld3 0.5.8
File Size Uploaded
mpld3-0.5.8.tar.gz 2.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for mpld3 0.5.8
File Interpreter ABI Platform
mpld3-0.5.8-py3-none-any.whl Python 3 none any Details

Total release size: 2.5 MB

Release files / mpld3-0.5.8.tar.gz

Download URL mpld3-0.5.8.tar.gz
Size 2.3 MB
Tags Source
SHA-256 checksum
How to use checksums
1a167dbef836dd7c66d8aa71c06a32d50bffa18725f304d93cb74fdb3545043b
BLAKE2b-256 checksum
How to use checksums
5ac2d6e19705072069d5564e45b0041d61fd1cc27c984e65d7621f13dcf79bfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.0

Release files / mpld3-0.5.8-py3-none-any.whl

Download URL mpld3-0.5.8-py3-none-any.whl
Size 201.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
41938e65de4ba41a1b53d92e7c8609e7172e09b33ef5db42bb6f73701106c8b7
BLAKE2b-256 checksum
How to use checksums
5ffc08fdadba29ebd37a402dd27048a7222a48075e281989a7a122fa1dcab065
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.0

Release history Release notifications | RSS feed

0.5.11

2 release files

0.5.10

2 release files

0.5.9

2 release files

This release

0.5.8 This release

2 release files

0.5.7

3 release files

0.5.6

2 release files

0.5.5

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page