home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 1494051039

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/7333#issuecomment-1494051039 https://api.github.com/repos/pydata/xarray/issues/7333 1494051039 IC_kwDOAMm_X85ZDWjf 85181086 2023-04-03T10:12:40Z 2023-04-03T10:12:40Z NONE

The reason for the difference in behavior between the two examples is that the first example has named coordinates ('A', 'B', 'C', 'X', 'Y') while the second example has default dimension names ('dim_0', 'dim_1', 'dim_2', 'dim_3', 'dim_4').

In the first example, when calling p.map_dataarray, the x and y arguments are passed as coordinate names ('B' and 'C') instead of dimension names, which is causing the error. The correct way to pass the dimension names would be to use da.dims to get the list of dimension names and pass them as strings:

p.map_dataarray(xr.plot.pcolormesh, y=da.dims[1], x=da.dims[2])

The reason for the difference in behavior between the two examples is that the first example has named coordinates ('A', 'B', 'C', 'X', 'Y') while the second example has default dimension names ('dim_0', 'dim_1', 'dim_2', 'dim_3', 'dim_4').

In the first example, when calling p.map_dataarray, the x and y arguments are passed as coordinate names ('B' and 'C') instead of dimension names, which is causing the error. The correct way to pass the dimension names would be to use da.dims to get the list of dimension names and pass them as strings:

p.map_dataarray(xr.plot.pcolormesh, y=da.dims[1], x=da.dims[2])

In the second example, the error message is more informative because the dimension names are already being used. The error message indicates that the valid options for the x argument are None, 'dim_3', and 'dim_4', which are the dimensions with index 3 and 4 in the data array. The correct way to pass the dimension names would be:

p.map_dataarray(xr.plot.pcolormesh, y='dim_1', x='dim_2') This will map the pcolormesh plot onto the dimensions 'dim_1' and 'dim_2', which correspond to the columns and rows of the contour plot.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  1468534020
Powered by Datasette · Queries took 0.578ms · About: xarray-datasette