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

Update README.rst #160

Merged
merged 1 commit into from
Sep 19, 2023
Merged

Update README.rst #160

merged 1 commit into from
Sep 19, 2023

Conversation

drf5n
Copy link
Contributor

@drf5n drf5n commented Sep 13, 2023

I needed to change this line to

section.plot(ax=ax1, x="mesh2d_face_x")

because of this error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[197], line 15
     13 uda.ugrid.plot(ax=ax0, vmin=-20, vmax=90, cmap="terrain")
     14 ax0.axhline(y=section_y, color="red")
---> 15 section.plot(ax=ax1, x="mesh2d_x")

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

File ~/anaconda3/envs/leafletNetcdf_2/lib/python3.11/site-packages/xarray/plot/dataarray_plot.py:306, in plot(darray, row, col, col_wrap, ax, hue, subplot_kws, **kwargs)
    302     plotfunc = hist
    304 kwargs["ax"] = ax
--> 306 return plotfunc(darray, **kwargs)

File ~/anaconda3/envs/leafletNetcdf_2/lib/python3.11/site-packages/xarray/plot/dataarray_plot.py:500, in line(darray, row, col, figsize, aspect, size, ax, hue, x, y, xincrease, yincrease, xscale, yscale, xticks, yticks, xlim, ylim, add_legend, _labels, *args, **kwargs)
    497     assert "args" not in kwargs
    499 ax = get_axis(figsize, size, aspect, ax)
--> 500 xplt, yplt, hueplt, hue_label = _infer_line_data(darray, x, y, hue)
    502 # Remove pd.Intervals if contained in xplt.values and/or yplt.values.
    503 xplt_val, yplt_val, x_suffix, y_suffix, kwargs = _resolve_intervals_1dplot(
    504     xplt.to_numpy(), yplt.to_numpy(), kwargs
    505 )

File ~/anaconda3/envs/leafletNetcdf_2/lib/python3.11/site-packages/xarray/plot/dataarray_plot.py:71, in _infer_line_data(darray, x, y, hue)
     68     raise ValueError("Cannot specify both x and y kwargs for line plots.")
     70 if x is not None:
---> 71     _assert_valid_xy(darray, x, "x")
     73 if y is not None:
     74     _assert_valid_xy(darray, y, "y")

File ~/anaconda3/envs/leafletNetcdf_2/lib/python3.11/site-packages/xarray/plot/utils.py:442, in _assert_valid_xy(darray, xy, name)
    440 if (xy is not None) and (xy not in valid_xy):
    441     valid_xy_str = "', '".join(sorted(tuple(str(v) for v in valid_xy)))
--> 442     raise ValueError(
    443         f"{name} must be one of None, '{valid_xy_str}'. Received '{xy}' instead."
    444     )

ValueError: x must be one of None, 'mesh2d_face_x', 'mesh2d_face_y', 'mesh2d_nFaces', 's', 'x', 'y'. Received 'mesh2d_x' instead.

I needed to change this line to 

    section.plot(ax=ax1, x="mesh2d_face_x")

because of this error:

```
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[197], line 15
     13 uda.ugrid.plot(ax=ax0, vmin=-20, vmax=90, cmap="terrain")
     14 ax0.axhline(y=section_y, color="red")
---> 15 section.plot(ax=ax1, x="mesh2d_x")

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

File ~/anaconda3/envs/leafletNetcdf_2/lib/python3.11/site-packages/xarray/plot/dataarray_plot.py:306, in plot(darray, row, col, col_wrap, ax, hue, subplot_kws, **kwargs)
    302     plotfunc = hist
    304 kwargs["ax"] = ax
--> 306 return plotfunc(darray, **kwargs)

File ~/anaconda3/envs/leafletNetcdf_2/lib/python3.11/site-packages/xarray/plot/dataarray_plot.py:500, in line(darray, row, col, figsize, aspect, size, ax, hue, x, y, xincrease, yincrease, xscale, yscale, xticks, yticks, xlim, ylim, add_legend, _labels, *args, **kwargs)
    497     assert "args" not in kwargs
    499 ax = get_axis(figsize, size, aspect, ax)
--> 500 xplt, yplt, hueplt, hue_label = _infer_line_data(darray, x, y, hue)
    502 # Remove pd.Intervals if contained in xplt.values and/or yplt.values.
    503 xplt_val, yplt_val, x_suffix, y_suffix, kwargs = _resolve_intervals_1dplot(
    504     xplt.to_numpy(), yplt.to_numpy(), kwargs
    505 )

File ~/anaconda3/envs/leafletNetcdf_2/lib/python3.11/site-packages/xarray/plot/dataarray_plot.py:71, in _infer_line_data(darray, x, y, hue)
     68     raise ValueError("Cannot specify both x and y kwargs for line plots.")
     70 if x is not None:
---> 71     _assert_valid_xy(darray, x, "x")
     73 if y is not None:
     74     _assert_valid_xy(darray, y, "y")

File ~/anaconda3/envs/leafletNetcdf_2/lib/python3.11/site-packages/xarray/plot/utils.py:442, in _assert_valid_xy(darray, xy, name)
    440 if (xy is not None) and (xy not in valid_xy):
    441     valid_xy_str = "', '".join(sorted(tuple(str(v) for v in valid_xy)))
--> 442     raise ValueError(
    443         f"{name} must be one of None, '{valid_xy_str}'. Received '{xy}' instead."
    444     )

ValueError: x must be one of None, 'mesh2d_face_x', 'mesh2d_face_y', 'mesh2d_nFaces', 's', 'x', 'y'. Received 'mesh2d_x' instead.
```
@Huite Huite merged commit e8ede68 into Deltares:main Sep 19, 2023
1 of 2 checks passed
@Huite
Copy link
Collaborator

Huite commented Sep 19, 2023

Thanks, indeed I forgot to update this!

@drf5n drf5n deleted the patch-1 branch September 19, 2023 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants