From 80c5ab884e00b287bfe91eba0f81fa1fcd4a0cc1 Mon Sep 17 00:00:00 2001 From: Roman Kushnir Date: Thu, 26 Sep 2024 14:36:15 +0200 Subject: [PATCH] Add current user app theme to matplotlib Figure viewer. --- ...sion_matrix_plot.csv => confusion_matrix_plot.csv} | 0 stubs/cl/runtime/views/stub_plots.py | 11 ++++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) rename stubs/cl/runtime/views/{test_confusion_matrix_plot.csv => confusion_matrix_plot.csv} (100%) diff --git a/stubs/cl/runtime/views/test_confusion_matrix_plot.csv b/stubs/cl/runtime/views/confusion_matrix_plot.csv similarity index 100% rename from stubs/cl/runtime/views/test_confusion_matrix_plot.csv rename to stubs/cl/runtime/views/confusion_matrix_plot.csv diff --git a/stubs/cl/runtime/views/stub_plots.py b/stubs/cl/runtime/views/stub_plots.py index 0681bce2..afb60145 100644 --- a/stubs/cl/runtime/views/stub_plots.py +++ b/stubs/cl/runtime/views/stub_plots.py @@ -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 @@ -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()