Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First example on https://xarray.dev/ does not run #9812

Closed
5 tasks
rsokolewicz opened this issue Nov 23, 2024 · 3 comments
Closed
5 tasks

First example on https://xarray.dev/ does not run #9812

rsokolewicz opened this issue Nov 23, 2024 · 3 comments
Labels

Comments

@rsokolewicz
Copy link

What happened?

There's an example on the home page: https://xarray.dev/ together with a notebook-like widget where the user is instructed to try out the code. The kernel however isn't preloaded with an installed version of matplotlib, so the example doesn't run:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[2], line 44
     41 data.mean(dim=["time", "lat"])
     43 # quick and convenient visualizations
---> 44 data.isel(lon=0).plot();
     46 # Pretty neat, eh? :)
     47 # For more, head over to the documentation page

File /lib/python3.12/site-packages/xarray/plot/accessor.py:48, in DataArrayPlotAccessor.__call__(self, **kwargs)
     46 @functools.wraps(dataarray_plot.plot, assigned=("__doc__", "__annotations__"))
     47 def __call__(self, **kwargs) -> Any:
---> 48     return dataarray_plot.plot(self._da, **kwargs)

File /lib/python3.12/site-packages/xarray/plot/dataarray_plot.py:309, in plot(darray, row, col, col_wrap, ax, hue, subplot_kws, **kwargs)
    305     plotfunc = hist
    307 kwargs["ax"] = ax
--> 309 return plotfunc(darray, **kwargs)

File /lib/python3.12/site-packages/xarray/plot/dataarray_plot.py:1571, in _plot2d.<locals>.newplotfunc(***failed resolving arguments***)
   1567 yplt, ylab_extra = _resolve_intervals_2dplot(yvalnp, plotfunc.__name__)
   1569 _ensure_plottable(xplt, yplt, zval)
-> 1571 cmap_params, cbar_kwargs = _process_cmap_cbar_kwargs(
   1572     plotfunc,
   1573     zval.data,
   1574     **locals(),
   1575     _is_facetgrid=kwargs.pop("_is_facetgrid", False),
   1576 )
   1578 if "contour" in plotfunc.__name__:
   1579     # extend is a keyword argument only for contour and contourf, but
   1580     # passing it to the colorbar is sufficient for imshow and
   1581     # pcolormesh
   1582     kwargs["extend"] = cmap_params["extend"]

File /lib/python3.12/site-packages/xarray/plot/utils.py:944, in _process_cmap_cbar_kwargs(func, data, cmap, colors, cbar_kwargs, levels, _is_facetgrid, **kwargs)
    942 cmap_kwargs.update((a, kwargs[a]) for a in cmap_args if a in kwargs)
    943 if not _is_facetgrid:
--> 944     cmap_params = _determine_cmap_params(**cmap_kwargs)
    945 else:
    946     cmap_params = {
    947         k: cmap_kwargs[k]
    948         for k in ["vmin", "vmax", "cmap", "extend", "levels", "norm"]
    949     }

File /lib/python3.12/site-packages/xarray/plot/utils.py:180, in _determine_cmap_params(plot_data, vmin, vmax, cmap, center, robust, extend, levels, filled, norm, _is_facetgrid)
    154 def _determine_cmap_params(
    155     plot_data,
    156     vmin=None,
   (...)
    165     _is_facetgrid=False,
    166 ):
    167     """
    168     Use some heuristics to set good defaults for colorbar and range.
    169 
   (...)
    178         Use depends on the type of the plotting function
    179     """
--> 180     import matplotlib as mpl
    182     if isinstance(levels, Iterable):
    183         levels = sorted(levels)

ModuleNotFoundError: No module named 'matplotlib'

image

I wanted to fix it and open a pull request, but I couldn't find where the home page is defined under /docs :')

What did you expect to happen?

No response

Minimal Complete Verifiable Example

No response

MVCE confirmation

  • Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • Complete example — the example is self-contained, including all data and the text of any traceback.
  • Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • New issue — a search of GitHub Issues suggests this is not a duplicate.
  • Recent environment — the issue occurs with the latest version of xarray and its dependencies.

Relevant log output

No response

Anything else we need to know?

No response

Environment

@rsokolewicz rsokolewicz added bug needs triage Issue that has not been reviewed by xarray team member labels Nov 23, 2024
Copy link

welcome bot commented Nov 23, 2024

Thanks for opening your first issue here at xarray! Be sure to follow the issue template!
If you have an idea for a solution, we would really welcome a Pull Request with proposed changes.
See the Contributing Guide for more.
It may take us a while to respond here, but we really value your contribution. Contributors like you help make xarray better.
Thank you!

@TomNicholas
Copy link
Member

Thank you for flagging this! We should definitely fix it 😅

I couldn't find where the home page is defined under /docs :')

The xarray.dev website is actually defined in an entirely separate repo - https://github.com/xarray-contrib/xarray.dev

@TomNicholas TomNicholas removed the needs triage Issue that has not been reviewed by xarray team member label Nov 23, 2024
@rsokolewicz
Copy link
Author

rsokolewicz commented Nov 23, 2024

cool. I'll close this here and open a ticket there :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants