{"id":5663,"library":"mpld3","title":"D3 Viewer for Matplotlib","description":"mpld3, currently at version 0.5.12, bridges Matplotlib's powerful plotting capabilities with D3.js for interactive web visualizations. It provides a straightforward API to export Matplotlib graphics to HTML, suitable for web pages, blogs, or Jupyter notebooks. The project's development is in maintenance mode, with maintainers reviewing pull requests but having limited time for issue resolution.","status":"maintenance","version":"0.5.12","language":"en","source_language":"en","source_url":"https://github.com/mpld3/mpld3","tags":["visualization","matplotlib","d3.js","interactive","web","jupyter-notebook"],"install":[{"cmd":"pip install mpld3","lang":"bash","label":"Pip"},{"cmd":"conda install mpld3","lang":"bash","label":"Conda"}],"dependencies":[{"reason":"Required for creating plots to be converted.","package":"matplotlib","optional":false},{"reason":"Used for templating the HTML output.","package":"jinja2","optional":false},{"reason":"Optional dependency for enhanced functionality within Jupyter Notebooks.","package":"ipython","optional":true}],"imports":[{"symbol":"mpld3","correct":"import mpld3"},{"note":"Using 'plt' as an alias is the conventional and recommended practice for matplotlib.","wrong":"import matplotlib.pyplot","symbol":"matplotlib.pyplot","correct":"import matplotlib.pyplot as plt"}],"quickstart":{"code":"import matplotlib.pyplot as plt\nimport mpld3\n\nfig, ax = plt.subplots()\nax.plot([3, 1, 4, 1, 5], 'ks-', mec='w', mew=5, ms=20)\nax.set_title(\"My Interactive Plot\")\n\n# To display in a browser:\nmpld3.show(fig)\n\n# To get HTML string:\n# html_output = mpld3.fig_to_html(fig)\n# print(html_output)","lang":"python","description":"This quickstart demonstrates how to create a simple Matplotlib plot and then use `mpld3.show()` to render it as an interactive D3.js visualization in your default web browser. Alternatively, `mpld3.fig_to_html()` can generate the HTML string for embedding."},"warnings":[{"fix":"Clear all output in the notebook (Cell -> All Output -> Clear), save the notebook, close the window, and then re-open it.","message":"When updating mpld3, particularly in Jupyter Notebooks, cached JavaScript libraries can cause unexpected behavior. The notebook might still use older versions of the JS library, even if the Python package is updated.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For large datasets, consider specialized tools that leverage data summarization or GPU acceleration, such as Bokeh or other dedicated big data visualization libraries.","message":"mpld3 is not designed for large datasets (plots with more than a few thousand elements). Performance for interactive features will degrade significantly due to its reliance on HTML SVG, which is not optimized for big data visualization.","severity":"gotcha","affected_versions":"All versions"},{"fix":"This is a known issue (GitHub #346) with no direct user-level fix provided; it requires an internal patch to mpld3's warning handling. Users might need to filter warnings manually if they find them disruptive.","message":"Importing mpld3 can trigger numerous deprecation warnings from `ipywidgets` in newer Python environments (e.g., Python 3.5+). This is due to broad warning filters applied by mpld3's internal `utils.py` module.","severity":"deprecated","affected_versions":"0.2+"},{"fix":"Refer to the official documentation and GitHub issues for current compatibility. If encountering issues with newer Python versions, consider using a compatible Python environment or checking for community workarounds.","message":"mpld3's compatibility documentation explicitly mentions Python versions 2.6-2.7 and 3.3-3.4. While it may run on newer Python 3 versions (e.g., 3.5+), these versions are not officially guaranteed to be fully supported or tested, which could lead to unexpected behavior or incompatibilities.","severity":"gotcha","affected_versions":"<=0.5.12"},{"fix":"Users may need to explore mpld3's plugin framework to implement custom interactive behaviors or adjust expectations for direct Matplotlib feature translation.","message":"Some advanced Matplotlib features, such as custom widgets or intricate tick label formatting (e.g., `ax.xaxis.set_ticklabels()`), may not be fully supported or accurately translated into the D3.js output, limiting full interactive parity with native Matplotlib figures.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}