Skip to content

Commit

Permalink
Use matplotlib styles instead of seaborn.set_theme
Browse files Browse the repository at this point in the history
Using seaborn.set_theme results in good looking figures but is a bit
draconian. Allowing the user to specify a matplotlib style instead makes
customization easier, and the user can always call seaborn.set_theme
themself if they want it.
  • Loading branch information
garland-culbreth committed Feb 2, 2025
1 parent b9f541b commit b91c8c7
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/pymdea/plot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Plotting functions."""

from typing import Literal, Self
from typing import Self

import matplotlib.pyplot as plt
import numpy as np
Expand All @@ -15,24 +15,21 @@ class DeaPlotter:
def __init__(
self: Self,
model: DeaEngine,
theme: Literal["ticks", "whitegrid", "darkgrid"] = "ticks",
colors: Literal["muted", "deep", "Set2", "tab10"] = "muted",
theme: None | str = None,
) -> Self:
"""Plot DEA results.
Parameters
----------
model : Self@DeaEngine
Object containing the results of a DEA analysis to be plotted.
theme : str {"ticks", "whitegrid", "darkgrid"}, optional, default: "ticks"
Name of a seaborn style. Passed through to
seaborn.set_theme().
colors : str {"muted", "deep", "Set2", "tab10"}, optional, default: "muted"
Name of a seaborn or matplotlib color palette. Passed
through to seaborn.set_theme().
theme : None | str, optional, default: None
Must be either None or a string corresponding to a
matplotlib.pyplot style.
"""
sns.set_theme(context="notebook", style=theme, palette=colors)
if theme is not None:
plt.style.use(style=theme)
self.window_lengths = model.window_lengths
self.entropies = model.entropies
self.delta = model.fit_coefficients[0]
Expand Down

0 comments on commit b91c8c7

Please sign in to comment.