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
ENH: Prototype new plotting API for bar plot, accept and return axes #3523
Conversation
86e85a1
to
df744ef
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3523 +/- ##
==========================================
+ Coverage 59.42% 60.65% +1.22%
==========================================
Files 90 90
Lines 12718 12722 +4
==========================================
+ Hits 7558 7716 +158
+ Misses 5160 5006 -154 ☔ View full report in Codecov by Sentry. |
@DanGolding you may wish to take a skim through this PR if you get a minute |
It seems unnecessary to me, unless this has become an established pattern in other libraries?
users can always end the line with a |
I added a proposed "checklist" for things that we wish to overhaul for each plot to #3411. I'll work through that for this PR as an example - in particular, we need more tests and to update the API example notebook. |
3587bc8
to
3c87705
Compare
# we show the data on auto only when there are no transforms (excluding getitem calls) | ||
if show_data == "auto": | ||
show_data = len(op_history) == 0 | ||
transforms = [t for t in op_history if t.get("name") != "__getitem__"] | ||
show_data = len(transforms) == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is one functional change that I needed to make in order to reproduce more closely the plots in the API example notebook.
In the API example notebook, many plots have show_data=True. This adds the small grey numbers on the left axis. It looks like this behaviour was then changed at some point to only show data values when there are no transforms applied.
However, I think show_data
still makes sense as True
for a single explanation when the only operation applied has been __getitem__
.
Before (show_data = False)
After (show_data = True)
Whilst we're at it, I updated the API examples notebook. Hopefully it should be executable on CI now. Reducing the sample size of the toy dataset from 32k to 2k rows sped up the runtime significantly, without changing the overall look or complexity of the example plots. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just a couple doc nitpicks from me
Co-authored-by: Tobias Pitters <31857876+CloseChoice@users.noreply.github.com>
Fab - I applied those changes, and shall merge shortly. Regarding the |
Overview
Supports #3411
Supports #3036
A prototype new standard API interface for the plots, using
plots.bar
as an example:ax
parameter to accept an existing matplotlib axesDiscussion
I do wonder if the
show
argument is really needed. In jupyter notebooks, I believeplt.show()
is called anyway after each cell, so this seems a little redundant. However, it does have the nice effect of returningNone
which avoids cluttering the output with the__repr__
of the axes object.I think changing the return type to
ax
fromfig
is technically a breaking change; but this was only a fairly recent addition, so it's probably not too significant.Checklist
From #3411
ax
parameter