Skip to content

Commit 700ee8e

Browse files
matplotlib
1 parent bf41195 commit 700ee8e

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

quarto/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
from quarto.theme import plotly_theme_colors, plotly_theme_brand, \
1010
altair_theme_colors, altair_theme_brand, \
1111
bokeh_theme_colors, bokeh_theme_brand, \
12-
great_tables_theme_colors, great_tables_theme_brand
12+
great_tables_theme_colors, great_tables_theme_brand, \
13+
matplotlib_theme_colors, matplotlib_theme_brand

quarto/theme.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,29 @@ def great_tables_theme_brand(brand_yml):
7373
fg = brand["color"]["foreground"]
7474
bg = brand["color"]["background"]
7575
return great_tables_theme_colors(bg, fg)
76+
77+
78+
def matplotlib_theme_colors(bg, fg, primary):
79+
import matplotlib as mpl
80+
from cycler import cycler
81+
mpl.rcParams["axes.facecolor"] = bg
82+
mpl.rcParams["axes.edgecolor"] = fg
83+
mpl.rcParams["axes.labelcolor"] = fg
84+
mpl.rcParams["axes.titlecolor"] = fg
85+
mpl.rcParams["figure.facecolor"] = bg
86+
mpl.rcParams["figure.edgecolor"] = fg
87+
mpl.rcParams["text.color"] = fg
88+
mpl.rcParams["xtick.color"] = fg
89+
mpl.rcParams["ytick.color"] = fg
90+
if primary:
91+
mpl.rcParams["axes.prop_cycle"] = cycler('color', [primary])
92+
93+
94+
def matplotlib_theme_brand(brand_yml):
95+
brand = yaml.safe_load(open(brand_yml).read())
96+
return partial(
97+
matplotlib_theme_colors,
98+
brand["color"]["background"],
99+
brand["color"]["foreground"],
100+
brand["color"]["primary"],
101+
)

0 commit comments

Comments
 (0)