Plotting with plotly backend

[1]:
# Basic imports
from physt.examples import normal_h2, normal_h1
from physt.plotting import plotly
import physt.plotting

import numpy as np
np.random.seed(42)

# Set that we want plotly
physt.plotting.set_default_backend("plotly")
[2]:
# Define the 1-D example
H = normal_h1()

The default plot is bar.

[3]:
H.plot()  # Same as H.plot.bar()
[4]:
H.plot.line()
[5]:
H.plot.scatter()

Plotly Figure object

If you want to further manipulate the figures, you can return them from the function as-is using the raw keyword.

[6]:
figure = H.plot.scatter(raw=True)
type(figure)
[6]:
plotly.graph_objs._figure.Figure

2D histograms

[7]:
H2 = normal_h2()
[8]:
# Default is heatmap
H2.plot()

Collections

[9]:
from physt import collection

collection = collection({
    "small": np.random.normal(160, 20, 600),
    "tall": np.random.normal(180, 20, 1000),
    "huge": np.random.normal(200, 20, 400),
    "gigantic": np.random.normal(220, 20, 200)
}, "human")
[10]:
collection.plot.line()
[11]:
# Let's see normalized histograms in the collection
collection.normalize_bins().plot(barmode="overlay", alpha=0.3)
[12]:
# ...and how they look like when stacked
collection.normalize_bins().plot(barmode="stack")