From f6dcea2e4c76fafdc04866acb93e6b72e3287549 Mon Sep 17 00:00:00 2001 From: marcosf2 Date: Fri, 8 May 2026 15:37:39 -0500 Subject: [PATCH] Fix plot handling in hvplotting.py to prevent AttributeError and register hvplot accessor for xarray --- src/labcore/analysis/hvplotting.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/labcore/analysis/hvplotting.py b/src/labcore/analysis/hvplotting.py index 4920e07..c88bc12 100644 --- a/src/labcore/analysis/hvplotting.py +++ b/src/labcore/analysis/hvplotting.py @@ -30,6 +30,7 @@ from pathlib import Path from typing import Any, Dict, Optional, Union +import hvplot.xarray # noqa: F401 — registers .hvplot accessor on xarray objects import numpy as np import pandas as pd import panel as pn @@ -1064,7 +1065,11 @@ def plot_panel(self) -> Any: ) else: raise NotImplementedError - plot = plot.cols(2) + if not isinstance(plot, str): + try: + plot = plot.cols(2) + except AttributeError: + pass return plot def fit_axis_options(self) -> Any: @@ -1322,11 +1327,10 @@ def plot_xr_as_2d( ylabel=dim_labels.get(y, y), clabel=f"Mean {dim_labels.get(d, d)}", ) - # FIXME: QuadMesh object has no attribute 'cols' error for longsweep try: return plot.cols(1) except AttributeError: - return "*Not a valid plot* Attribute Error occurred" + return plot else: return "*Not a valid plot*"