Quick Start

matplotly provides three ways to open the interactive editor.

1. Pass a figure directly

%matplotlib widget
import matplotlib.pyplot as plt
from matplotly import matplotly

fig, ax = plt.subplots()
ax.plot([1, 2, 3], [1, 4, 9])
matplotly(fig)

2. Decorator mode

@matplotly
def my_plot():
    plt.plot([1, 2, 3], [1, 4, 9])

my_plot()

The decorator calls your function, captures plt.gcf(), and opens the editor.

3. Context manager

with matplotly() as pb:
    fig, ax = plt.subplots()
    ax.plot([1, 2, 3], [1, 4, 9])

On exit, the context manager captures the current figure and launches the editor.