You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When working on updating docs depedencies in #4596, I found the following two examples that don't work on the latest xarray.
import plotly.express as px
import xarray as xr
# Load xarray from dataset included in the xarray tutorial
airtemps = xr.tutorial.open_dataset('air_temperature').air.sel(lon=250.0)
fig = px.imshow(airtemps.T, color_continuous_scale='RdBu_r', origin='lower')
fig.show()
import plotly.express as px
import xarray as xr
# Load xarray from dataset included in the xarray tutorial
airtemps = xr.tutorial.open_dataset('air_temperature').air.sel(lon=250.0)
fig = px.imshow(airtemps.T, color_continuous_scale='RdBu_r', origin='lower')
fig.show()
Show the following error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[1], line 5
3 # Load xarray from dataset included in the xarray tutorial
4 airtemps = xr.tutorial.open_dataset('air_temperature').air.sel(lon=250.0)
----> 5 fig = px.imshow(airtemps.T, color_continuous_scale='RdBu_r', origin='lower')
6 fig.show()
File ~/miniconda3/envs/plotly-dev-2/lib/python3.10/site-packages/plotly/express/_imshow.py:300, in imshow(img, zmin, zmax, origin, labels, x, y, animation_frame, facet_col, facet_col_wrap, facet_col_spacing, facet_row_spacing, color_continuous_scale, color_continuous_midpoint, range_color, title, template, width, height, aspect, contrast_rescaling, binary_string, binary_backend, binary_compression_level, binary_format, text_auto)
298 labels["facet_col"] = facet_label
299 if labels.get("color", None) is None:
--> 300 labels["color"] = xarray.plot.utils.label_from_attrs(img)
301 labels["color"] = labels["color"].replace("\n", "<br>")
302 else:
File ~/miniconda3/envs/plotly-dev-2/lib/python3.10/site-packages/xarray/plot/utils.py:529, in label_from_attrs(da, extra)
526 else:
527 name = ""
--> 529 units = _get_units_from_attrs(da)
531 # Treat `name` differently if it's a latex sequence
532 if name.startswith("$") and (name.count("$") % 2 == 0):
File ~/miniconda3/envs/plotly-dev-2/lib/python3.10/site-packages/xarray/plot/utils.py:504, in _get_units_from_attrs(da)
502 pint_array_type = DuckArrayModule("pint").type
503 units = " [{}]"
--> 504 if isinstance(da.data, pint_array_type):
505 return units.format(str(da.data.units))
506 if "units" in da.attrs:
File ~/miniconda3/envs/plotly-dev-2/lib/python3.10/site-packages/xarray/core/common.py:285, in AttrAccessMixin.__getattr__(self, name)
283 with suppress(KeyError):
284 return source[name]
--> 285 raise AttributeError(
286 f"{type(self).__name__!r} object has no attribute {name!r}"
287 )
AttributeError: 'DataArray' object has no attribute 'data'
When working on updating docs depedencies in #4596, I found the following two examples that don't work on the latest xarray.
Show the following error:
requirements:
The text was updated successfully, but these errors were encountered: