-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Add support for multiple hatches, edgecolors and linewidths in histograms #28073
base: main
Are you sure you want to change the base?
Conversation
I'd suggest showing what this does with an example either in the GitHub pr description, or ideally in the gallery |
I'm not really sure if I need to add a new test or just modify an exisiting one(test_hist_stacked_bar) in test_axes.py |
I guess there are two things here:
|
pinging @story645 for review. The failing tests are unrelated |
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.
also needs updated documentation that the patch properties are now vectorized (@timhoffm any concerns here?)
What should we be concerned about? We already have vectorized
This should also get a what's new entry. |
My bias is vectorize everything so I don't have concerns, but in the past for some vectorization discussions there have been concerns about the tradeoffs. But if there isn't opposition, awesome! |
I don't see any drawbacks for |
So we are planning to vectorize all parameters of Patches? Like joinstyle, capstyle etc. |
Not at this time w/ the current architecture, especially because nobody has asked for those. |
Specify extensions for test Added modified baseline images Modified test for histogram with single parameters Fixed test Add modified baseline images
Codecov is acting fishy, it passed once and failed again after squashing. Anything else to add/change? |
As of the last commit, this behavior is consistent for all histtypes unless mentioned otherwise:
|
@Impaler343 I started trying to flow chart that and then realized it's probably clearer as a table. Let me know if this jives with what you're saying:
|
Have bolded the corrected ones |
I'm unable to fix CircleCI errors for docs. Could someone help me out? |
Hi, so the error is in your what's new: /home/circleci/project/doc/users/next_whats_new/histogram_vectorized_parameters.rst:47: WARNING: Explicit markup ends without a blank line; unexpected unindent. error: https://app.circleci.com/pipelines/github/matplotlib/matplotlib/31532/workflows/2533c013-7833-4d0c-ae72-dead7c7fbc76/jobs/83481?invite=true#step-113-207133_109 |
Ok it turns out the vectorization of
|
I think this input is ambiguous cause it can mean either:
So I think it's ok to error out (unless/until someone comes around expecting 1 or 2) but we should maybe special case and have a better error message, like if not all(colors) (if any are NaN) "Ambiguous color specification: colors in the list may not be None" Or something like that. |
Added baseline images Modified test to pass codecov, added plot in whats new entry Fix test Added baseline images
Minor fix Fix docs
Removed figsize from test Add multiple baseline image names Fixed test? Fixed test? Removed parametrize usage Add baseline images Add baseline image Fix docs Fix docs Deleted baseline images, changed test Fix test Fix test
Handled passing None list
The added lines have all been covered, codecov seems to still fail |
@@ -4603,6 +4603,36 @@ def test_hist_stacked_bar(): | |||
ax.legend(loc='upper right', bbox_to_anchor=(1.0, 1.0), ncols=1) | |||
|
|||
|
|||
@pytest.mark.parametrize("histtype", ["step", "stepfilled"]) | |||
@pytest.mark.parametrize("color", [["blue", "green", "brown"], [None]*3]) |
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.
@pytest.mark.parametrize("color", [["blue", "green", "brown"], [None]*3]) | |
@pytest.mark.parametrize("color", [["blue", "green", "brown"], None) |
I'd check the [None]*3 case as part of the error message test for the "["blue", None, etc]" case
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.
I figured we dont need an error message with the current modification
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.
The current modification handles [None, "blue", None] by assigned the rcparam color to None and uses the specified color wherever specified. Should be fine?
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.
Should be fine?
I'd rather it error out b/c of the ambiguity -> do you want the default param or do you want the next entry in the color cycle?
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.
Default param seems more logical to me, but no harm in adding the warning I guess. But i strongly feel people wont be expecting the color cycle after passing None explicitly. Isn't the color cycle called to fill up the absence of any colors explicitly mentioned?
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.
Isn't the color cycle called to fill up the absence of any colors explicitly mentioned?
Yeah, so here the question is with [None, 'blue', None]
does the user intend that these are 3 distinct datasets and therefore that the color cycle should kick in, or that they're just using [None, 'blue', None]
cause those two can be the same default color.
Is possibly a call for @timhoffm or something that should go on the project call (I won't be there this week, but you're welcome to come) thursday https://scientific-python.org/calendars/
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.
I think this is good +- some grammer nits, but I'm gonna put on the needs discussion
label b/c I think the [none, paramater, none]
case needs discussion.
rebase will fix the pr-cleanliness: https://matplotlib.org/devdocs/devel/development_workflow.html#rewrite-commit-history
Coverage is complaining that the no patch case is never tested:
https://app.codecov.io/gh/matplotlib/matplotlib/pull/28073?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=checks&utm_campaign=pr+comments&utm_term=matplotlib#7e79bc5b4cdd21de353697e9ada248b7-R7229
ETA: this can be a separate test!
|
||
.. plot:: | ||
:include-source: true | ||
:alt: Four charts, each displaying stacked histograms of three Poisson distributions. Each chart differentiates the histograms using various parameters: ax1 uses different linewidths, ax2 uses different hatches, ax3 uses different edgecolors, and ax4 uses different facecolors. Edgecolors have ax1 and ax3 as well to accentuate the differences between the histograms. |
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.
:alt: Four charts, each displaying stacked histograms of three Poisson distributions. Each chart differentiates the histograms using various parameters: ax1 uses different linewidths, ax2 uses different hatches, ax3 uses different edgecolors, and ax4 uses different facecolors. Edgecolors have ax1 and ax3 as well to accentuate the differences between the histograms. | |
:alt: Four charts, each displaying stacked histograms of three Poisson distributions. Each chart differentiates the histograms using various parameters: ax1 uses different linewidths, ax2 uses different hatches, ax3 uses different edgecolors, and ax4 uses different facecolors. Each histogram in ax1 and ax3 also has a different edgecolor. |
grammar/construction
# * linestyles | ||
# | ||
# | ||
# Histograms with Edge-Colors |
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.
# Histograms with Edge-Colors | |
# Edge colors |
I think you can just differentiate on property b/c it's the histograms page
@@ -4603,6 +4603,36 @@ def test_hist_stacked_bar(): | |||
ax.legend(loc='upper right', bbox_to_anchor=(1.0, 1.0), ncols=1) | |||
|
|||
|
|||
@pytest.mark.parametrize("histtype", ["step", "stepfilled"]) | |||
@pytest.mark.parametrize("color", [["blue", "green", "brown"], [None]*3]) |
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.
Isn't the color cycle called to fill up the absence of any colors explicitly mentioned?
Yeah, so here the question is with [None, 'blue', None]
does the user intend that these are 3 distinct datasets and therefore that the color cycle should kick in, or that they're just using [None, 'blue', None]
cause those two can be the same default color.
Is possibly a call for @timhoffm or something that should go on the project call (I won't be there this week, but you're welcome to come) thursday https://scientific-python.org/calendars/
PR summary
Closes #26718 Distributes keyword args passed to each Patch using a cycler. Probably not the best way to do this?
PR checklist