Skip to content

Commit

Permalink
Add current user app theme to matplotlib Figure viewer.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Kushnir authored and alexandervsokol committed Sep 26, 2024
1 parent a1dfe62 commit 80c5ab8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion stubs/cl/runtime/views/stub_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import pandas as pd

from cl.runtime import RecordMixin, viewer
from cl.runtime.backend.core.ui_app_state import UiAppState
from cl.runtime.plots.confusion_matrix_plot import ConfusionMatrixPlot
from cl.runtime.plots.confusion_matrix_plot_style import ConfusionMatrixPlotStyle
from cl.runtime.records.record_mixin import TKey
from stubs.cl.runtime.views.stub_plots_key import StubPlotsKey

Expand All @@ -32,10 +34,17 @@ def get_key(self) -> TKey:

@viewer
def confusion_matrix_plot(self):
raw_data = pd.read_csv(Path(__file__).resolve().parent / "./test_confusion_matrix_plot.csv")
"""Matplotlib Figure viewer with theme."""

raw_data = pd.read_csv(Path(__file__).resolve().parent / "./confusion_matrix_plot.csv")

matrix_plot_style = ConfusionMatrixPlotStyle()
matrix_plot_style.dark_theme = UiAppState.get_current_user_app_theme() == "Dark"

matrix_plot = ConfusionMatrixPlot()
matrix_plot.title = "Confusion Matrix"
matrix_plot.expected_categories = raw_data["True Category"].values.tolist()
matrix_plot.received_categories = raw_data["Predicted"].values.tolist()
matrix_plot.style = matrix_plot_style

return matrix_plot.create_figure()

0 comments on commit 80c5ab8

Please sign in to comment.