PyData Library Styles#

This theme has built-in support and special styling for several major visualization libraries in the PyData ecosystem. This ensures that the images and output generated by these libraries looks good for both light and dark modes. Below are examples of each that we use as a benchmark for reference.

Pandas#

import numpy as np
import pandas as pd

rng = np.random.default_rng()
data = rng.standard_normal((100, 3))
df = pd.DataFrame(data, columns=['a', 'b', 'c'])
df
a b c
0 -0.854276 -0.930686 0.553910
1 0.129202 1.498069 -0.582266
2 -0.071667 0.057413 -0.472116
3 -0.269303 0.793755 0.681351
4 0.774877 -0.331344 -0.450687
... ... ... ...
95 -0.323789 -0.620047 -1.975732
96 0.020069 0.499633 -0.537503
97 -1.090504 -0.519153 0.944534
98 -0.063159 -1.006629 -0.074277
99 -1.849437 -0.007807 -0.035609

100 rows × 3 columns

Matplotlib#

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.scatter(df["a"], df["b"], c=df["b"], s=3)
<matplotlib.collections.PathCollection at 0x7f9e7f008910>
../_images/284868da7b687131daeccafb165b3af91f675d98042debf42a5141cd4da94a15.png

and with the Matplotlib plot directive:

(Source code, png, hires.png, pdf)

../_images/pydata-1.png

Plotly#

The HTML below shouldn’t display, but it uses RequireJS to make sure that all works as expected. If the widgets don’t show up, RequireJS may be broken.

import plotly.io as pio
import plotly.express as px
import plotly.offline as py

pio.renderers.default = "notebook"

df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species", size="sepal_length")
fig