Add DataArray.epoch.plot() accessor to fix default axes for 2D data when plotting with xarray#107
Conversation
|
I'm not sure about modifying default Xarray behaviour, as this could result in unwanted surprises for users. I'd rather implement our own plotting functions under the |
|
I think this is looking good. Is it ready for review? The PR name should also probably be changed. |
DataArray.epoch.plot() accessor to fix default axes for 2D data when plotting with xarray
|
Yep, all ready for review, cheers :) |
LiamPattinson
left a comment
There was a problem hiding this comment.
Looks good!
I have some concerns about calling plt.subplots() in the tests and then plt.close at the end, as if multiple tests fail then a lot of matplotlib figures could accumulate in the background. One solution might be to use yield fixtures:
@pytest.fixture
def subplots():
# You could get fancy and pass rows/cols to the fixture
# Let's keep it easy here...
fig, ax = plt.subplots()
yield (fig, ax)
plt.close(fig)
def test_something(subplots)
fix, ax = subplots
# ... do the test ...I haven't tested this myself though, so it might take some experimentation.
|
That's a really good point, and your code worked on the first try. Thanks! |
Fed up with xarray plotting the axes in reverse and it's going to be a pain point during the EPOCH workshop so this is my attempt to address the issue by developing our own plotting accessor that inherits the default behaviour of the
xarray.plotmethod while also passing the correct axes for 2D data