Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Changed 'colors' parameter in PyPlot vlines/hlines and Axes vlines/hlines to default to configured rcParams 'lines.color' option #16953

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

Merged
merged 1 commit into from
Jun 1, 2020

Conversation

McCoubs
Copy link
Contributor

@McCoubs McCoubs commented Mar 30, 2020

PR Summary

Addresses issue #16482, wherein the configured 'lines.color' parameter of rcParams was not being used as the default parameter for the vlines/hlines methods of both the PyPlot and Axes API.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@tacaswell tacaswell added this to the v3.3.0 milestone Mar 30, 2020
@tacaswell
Copy link
Member

Can you please use check_figures_equal for the new tests? (see the last two paragraphs of https://matplotlib.org/devel/testing.html?highlight=check_figures_equal#writing-an-image-comparison-test) .

I think the only change we actually need here is for the default to be None and then a test that changing the rcparam causes the color to change.

Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please:

  • fix implementation
  • remove new images (and rebase out of history)

@McCoubs
Copy link
Contributor Author

McCoubs commented Mar 30, 2020

@tacaswell I updated the implementation inline with your review, as well as rebased the image comparators out of the git history

@tacaswell
Copy link
Member

Thanks @McCoubs ! This is definitely heading in the right direction.

@McCoubs
Copy link
Contributor Author

McCoubs commented Apr 1, 2020

@tacaswell thanks for the encouragement, I've updated again inline with your comments

@tacaswell
Copy link
Member

The tests look great. Only a minor change to the implementation and getting the docs to build left!

@McCoubs
Copy link
Contributor Author

McCoubs commented Apr 3, 2020

@tacaswell @QuLogic I've made changes inline with your comments

Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rebase to remove the merges, and maybe squash down the commits a bit?

@@ -3977,6 +3977,17 @@ def test_vlines():
ax5.set_xlim(0, 15)


@check_figures_equal(extensions=["png"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A figure comparison is more effort than needed. One could simply create the colors of the returned LineCollection.

I'm not insisting on that type of test here, but IMHO it would be more compact and faster. I've not timed figure comparisons, but since the test suite already runs for a long time, it may be worth keeping an eye at adding efficient tests.

@tacaswell tacaswell dismissed their stale review April 3, 2020 23:37

outdated

@McCoubs McCoubs force-pushed the iss-16482 branch 2 times, most recently from 907c167 to 03277e7 Compare April 5, 2020 19:20
@McCoubs
Copy link
Contributor Author

McCoubs commented Apr 5, 2020

@QuLogic @tacaswell I've updated with your review and squashed/rebased away any unnecessary commits

@QuLogic
Copy link
Member

QuLogic commented May 1, 2020

I approved before, and still approve, but tests need to be passing. See also @timhoffm's suggestion.

@tacaswell
Copy link
Member

@McCoubs This needs another rebase. I tried to do it and push to your branch but it won't let me (you must have un-checked the "allow maintainers to push" box?).

@tacaswell
Copy link
Member

And as long as you are rebasing would you mind also squashing to one commit?

@McCoubs
Copy link
Contributor Author

McCoubs commented May 20, 2020

@tacaswell I rebased and squashed into 1 commit, but I don't seem to see the checkbox you mentioned for "allow maintainers to push"

@QuLogic
Copy link
Member

QuLogic commented May 20, 2020

It should be at the end of the sidebar on the right, though maybe it's not really needed now.

@QuLogic
Copy link
Member

QuLogic commented May 27, 2020

This needs a rebase again; also see @timhoffm's comments about the tests.

@timhoffm
Copy link
Member

As written above, I'd prefer rewriting the tests but I'm not strictly insisting. Either way, please acknowledge the proposal and comment why you would or would not follow it.

@McCoubs
Copy link
Contributor Author

McCoubs commented May 29, 2020

@timhoffm sorry about the slow response time; due to current circumstances I have been quite busy. After considering your proposal I agree that asserting the colours from the LineCollection matches expected will be faster. I'll update and rebase with the change

…ine with issue matplotlib#16482

added test coverage for changes to pyplot hlines() and vlines() interface

adding API changes to api_changes

updated Axes.vlines and Axes.hline docstring inline with changes

updated spacing to be 2 line compliant

updated implementation for iss-16482 inline with review comments

removed unnecessary import of image_comparator decorator

running boilerplate.py to update vlines/hlines methods

updating inline with review comments

fixing flake8 errors

updating inline with reviewer comments

updating inline with reviewer comments

updated vlines/hlines default color tests inline with code review
@timhoffm timhoffm merged commit f48e59c into matplotlib:master Jun 1, 2020
@QuLogic QuLogic changed the title Changed 'colors' paramater in PyPlot vlines/hlines and Axes vlines/hlines to default to configured rcParams 'lines.color' option Changed 'colors' parameter in PyPlot vlines/hlines and Axes vlines/hlines to default to configured rcParams 'lines.color' option Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants