Metadata-Version: 2.1
Name: h2o-nitro-matplotlib
Version: 0.2.2
Summary: matplotlib plugin for H2O Nitro
Home-page: https://github.com/h2oai/nitro-matplotlib
Author: Prithvi Prabhu
Author-email: prithvi.prabhu@gmail.com
License: UNKNOWN
Project-URL: Documentation, https://github.com/h2oai/nitro-matplotlib
Project-URL: Source, https://github.com/h2oai/nitro-matplotlib
Project-URL: Issues, https://github.com/h2oai/nitro-matplotlib/issues
Platform: UNKNOWN
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Communications :: Chat
Classifier: Topic :: Scientific/Engineering :: Visualization
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Software Development :: Widget Sets
Classifier: Topic :: System :: Distributed Computing
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: matplotlib
Requires-Dist: h2o-nitro (>=0.9.2)

# Matplotlib plugin for H2O Nitro

This plugin lets you use [Matplotlib](https://matplotlib.org/stable/index.html)
and [Seaborn](https://seaborn.pydata.org/) visualizations in [Nitro](https://github.com/h2oai/nitro) apps.

**Warning: Try to avoid pyplot in web apps!** pyplot maintains references to the opened figures to make show() work, but
this will cause memory leaks unless the figures are properly closed[^1].

[^1]: See [Matplotlib docs on embedding](https://matplotlib.org/3.5.0/gallery/user_interfaces/web_application_server_sgskip.html)

## Demo

### Matplotlib

![Matplotlib](demo_matplotlib.gif)

[View source](examples/matplotlib_basic.py).

### Seaborn

![Seaborn](demo_seaborn.gif)

[View source](examples/seaborn_basic.py).


## Install

```
pip install h2o-nitro-matplotlib
```

## Usage

1. Import the plugin:


```py
from h2o_nitro_matplotlib import matplotlib_plugin, matplotlib_box
```


2. Register the plugin:

```py
nitro = View(main, title='My App', caption='v1.0', plugins=[matplotlib_plugin()])
```

3. Use the plugin:

```py 
# Make a figure:
x = np.linspace(0, 2, 100)  # Sample data.
fig = Figure()
ax = fig.subplots()
ax.plot(x, x, label='linear')  # Plot some data on the axes.
ax.plot(x, x ** 2, label='quadratic')  # Plot more data on the axes...
ax.plot(x, x ** 3, label='cubic')  # ... and some more.
ax.set_xlabel('x label')  # Add an x-label to the axes.
ax.set_ylabel('y label')  # Add a y-label to the axes.
ax.legend()  # Add a legend.

# Display the figure:
view(matplotlib_box(fig))
```

## Change Log

- v0.2.1 - Jun 09, 2022
  - Fixed
     - Don't return value from plots.
- v0.2.0 - May 30, 2022
   - Added
      - Use global pyplot if a figure is not passed (for Seaborn support).
- v0.1.0 - May 29, 2022
  - Initial Version


