DataArray plotting: pyplot compat and passing the style
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
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, '.-')
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reported examples for DataArray.plot, DataArray.plot.line, and pyplot.plot, comparing them with the working to_series() cases. Trace how style arguments and DataArray coordinates are passed through these plotting entry points; done means style='.-' works and pyplot.plot(arr, '.-') retains the coordinates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- matplotlib, pandas, python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100