Skip to main content

Render Matplotlib plots as HTML objects in Jupyter, so that they can be placed in HTML tables, downloaded on click, and more

Project description

This package can be used to render Matplotlib plots as HTML objects in Jupyter, so that they can be placed in HTML tables, downloaded on click, and more.

Installation

pip install html_plot

Examples

import pandas as pd
my_plot = pd.DataFrame([[1,2,3],[4,5,6]]).plot()

Simple usage

html_plot.display(my_plot)

Advanced usage

Adjust Figure and Axes (e.g. figsize, title)

plot_dim = html_plot.get_dim(my_plot.get_figure())
plot_dim.figsize *= 1.5
ax = html_plot.ax("This is my plot", **plot_dim)
my_html_plot = pd.DataFrame([[1,2,3],[4,5,6]]).plot(ax=ax)

Output HTML string

html_str = html_plot.html_str(my_html_plot)
print(html_str)

Output an IPython.display.HTML object

import IPython.display
html_obj = html_plot.HTML(my_html_plot)
IPython.display.display(html_obj)

Display the object using a wrapper for IPython.display.display()

html_plot.display(my_html_plot)

Licence

This work is dual-licensed under the Open Software License 3.0 and the Affero GNU General Public License 3.0. You can choose one of them if you use this work.

SPDX-License-Identifier: OSL-3.0 OR AGPL-3.0-or-later

  • The primary, more permissive licence is OSL-3.0, which allows the package to be used in any software project, regardless of the project's licence (open or closed source, commercial or non-commercial).
  • If you distribute software that uses a modified version of this package, the licence requires you to release only the code of the modified package, not the whole software project.
  • You are very welcome to do the above in the form of pull requests.
  • In other words, it's a reasonable, LGPL-like weak copyleft that doesn't try to infect all your software with a particular licence.
  • See the explanation and rationale for OSL-3.0 written by the author of the licence.
  • The alternative licence is AGPL-3.0, which allows the package to be combined with GPL-3.0 code.
  • Under both OSL-3.0 and AGPL-3.0, the aforementioned weak copyleft is also triggered by using the software over a network. In today's age of web apps, it makes no sense to have different terms depending on the technical details of how the software interacts with the user (locally or over a network). It's surprising how few open-source licences have caught up with the times.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

html_plot-0.1.4.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

html_plot-0.1.4-py3-none-any.whl (3.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page