themes: style once, plot everywhere
Universal theme styling across the different python visualization libraries. The package also contains out-of-the-box themes (e.g., a financial news theme) for instant use.
The full example in a live notebook is available below. Here are the key snippets,
Libraries and data
import themes
from themes import datasets
themes.register()
markets = datasets.load_markets()
Visualization with matplotlib
import matplotlib.pyplot as plt
with plt.style.context('capon'):
markets.pivot_table(index='timestamp', columns='symbol', values='relative_price').plot()
Visualization with altair
import altair as alt
with alt.themes.enable('capon'):
display(
alt.Chart(markets)
.mark_line(interpolate="monotone")
.encode(
x=alt.X("timestamp", title=None, axis=alt.Axis(format="%b %y")),
y=alt.Y("relative_price", title="Relative Price", axis=alt.Axis(format="+%")),
color="symbol",
tooltip=["timestamp", "symbol", alt.Tooltip("relative_price", format="+.2%")],
)
.properties(
title={
"text": f"Market Indexes Change",
"subtitle": f"Relative to {markets['timestamp'].dt.date.min()}",
},
width=600,
height=200,
)
)
Install latest release version via pip
$ pip install themes
Install latest development version via pip
pip install git+https://github.com/gialdetti/themes.git
git clone [email protected]:gialdetti/themes.git
cd themes
pip install -e .
All examples are located in examples folder.
Theme | MyBinder | Colab |
---|---|---|
Markets |
After installation, you can launch the test suite:
$ pytest