From 1e1ce26adffcab2a637cc5c70496787739963ccb Mon Sep 17 00:00:00 2001 From: Sebastian Weigand Date: Sun, 24 Oct 2021 20:29:24 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20broken=20'plot=5Fdata=5Fov?= =?UTF-8?q?erview'=20(#42)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🩹 Moved imports needed at runtime up from TYPE_CHECKING if block * 👌 Changed defaul figsize of plot_data_overview to (15, 10)) * 👌 Changed dataset in plot_data_overview to also be allowed to be a path That way there is consistent behavior across high level plotting functions. --- pyglotaran_extras/plotting/plot_data.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pyglotaran_extras/plotting/plot_data.py b/pyglotaran_extras/plotting/plot_data.py index 59b64ea0..84d2b2f2 100644 --- a/pyglotaran_extras/plotting/plot_data.py +++ b/pyglotaran_extras/plotting/plot_data.py @@ -1,9 +1,12 @@ from __future__ import annotations from typing import TYPE_CHECKING +from typing import cast import matplotlib.pyplot as plt +from matplotlib.axis import Axis +from pyglotaran_extras.io.load_data import load_data from pyglotaran_extras.plotting.plot_svd import plot_lsv_data from pyglotaran_extras.plotting.plot_svd import plot_rsv_data from pyglotaran_extras.plotting.plot_svd import plot_sv_data @@ -11,26 +14,24 @@ __all__ = ["plot_data_overview"] if TYPE_CHECKING: - from typing import cast - - import xarray as xr - from matplotlib.axis import Axis from matplotlib.figure import Figure from matplotlib.pyplot import Axes + from pyglotaran_extras.types import DatasetConvertible + def plot_data_overview( - dataset: xr.Dataset, + dataset: DatasetConvertible, title: str = "Data overview", linlog: bool = False, linthresh: float = 1, - figsize: tuple[int, int] = (30, 15), + figsize: tuple[int, int] = (15, 10), ) -> tuple[Figure, Axes]: """Plot data as filled contour plot and SVD components. Parameters ---------- - dataset : Dataset + dataset : DatasetConvertible Dataset containing data and SVD of the data. title : str, optional Title to add to the figure., by default "Data overview" @@ -45,6 +46,8 @@ def plot_data_overview( tuple[Figure, Axes] Figure and axes which can then be refined by the user. """ + dataset = load_data(dataset) + fig = plt.figure(figsize=figsize) data_ax = cast(Axis, plt.subplot2grid((4, 3), (0, 0), colspan=3, rowspan=3, fig=fig)) lsv_ax = cast(Axis, plt.subplot2grid((4, 3), (3, 0), fig=fig))