Skip to content

DataArray plotting: pyplot compat and passing the style #2837

Open
@aldanor

Description

@aldanor

These are two unrelated issues in one really that I've noticed while trying to plot things directly from DataArray objects.


The following works as expected, by converting DataArray to pandas first)

>>> arr.to_series().plot(style='.-')
>>> arr.to_series().plot.line(style='.-')

Passing Series to pyplot.plot() directly also works and retains index:

>>> plt.plot(arr.to_series(), '.-')

Trying to set style directly when plotting from DataArray doesn't work:

>>> arr.plot(style='.-')
AttributeError: Unknown property style
>>> arr.plot.line(style='.-')
AttributeError: Unknown property style

Passing DataArray to pyplot.plot() loses index:

>>> plt.plot(arr, '.-')
# works but loses coords; same as plot.plot(arr.values, '.-')

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions