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

Fix label on unnamed data array #1025

Merged
merged 2 commits into from
Mar 6, 2023
Merged

Fix label on unnamed data array #1025

merged 2 commits into from
Mar 6, 2023

Conversation

jsignell
Copy link
Member

Closes #666

This resolves the MRE in the original issue. I didn't quite get around to adding a test though 😬

import xarray as xr
import numpy as np
import hvplot.xarray

ny, nx = (30, 20)
x = np.linspace(0, 1, nx)
y = np.linspace(0, 2, ny)
coords={'y': ('y', y), 'x': ('x', x)}
foo = xr.DataArray(np.random.rand(ny, nx), dims=['y', 'x'], coords=coords)

# works
foo.hvplot('x', 'y', label='Foo') 

@maximlt
Copy link
Member

maximlt commented Mar 5, 2023

Thanks @jsignell ! I have added a couple of tests in c206b3b

Another note for myself :) I was wondering why label took precedence over value_label in the fix. That's actully already baked in in multiple places in the converter, so the fix nicely aligns that.

name = data.name or self.label or self.value_label

@maximlt maximlt merged commit a87d352 into main Mar 6, 2023
@maximlt maximlt deleted the jsignell/fix-da-no-name branch March 6, 2023 18:54
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.

Adding label to xarray plot produces KeyError
2 participants