FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

negative_linestyles kwarg in contour.py by andrew-fennell · Pull Request #23266 · matplotlib/matplotlib · GitHub

Repository navigation

negative_linestyles kwarg in contour.py - #23266

Merged
tacaswell merged 2 commits into
matplotlib:mainfrom
andrew-fennell:negative_linestyles
Jun 24, 2022
Merged

tacaswell merged 2 commits into
matplotlib:mainfrom
andrew-fennell:negative_linestyles

Conversation

andrew-fennell commented Jun 14, 2022 •
edited
Loading

Copy link
Copy Markdown
Contributor

PR Summary

I made the negative_linestyles for contours toggle-able via kwarg. The only way to toggle this currently is with rcParams.

I am re-opening this issue from a fresh branch. There was some discussion in #23102.

In the attached issue, we had some discussion on whether this is a good idea or not, but I think it is worth considering. We can maintain current functionality and just apply the kwarg if it is defined. This will not break previous functionality. I wrote some tests for this, but I know they can be improved. I'm not completely certain on using baseline_images with parametrized inputs.

Please use this PR and the attached issue to discuss whether this is a good idea or not. I'm happy to take this in a different direction if there are some better ideas!

Closes #23028

Previous

plt.rcParams['contour.negative_linestyle'] = 'solid'
fig, ax = plt.subplots()
CS = ax.contour(X, Y, Z, 6, colors='k')  # Negative contours default to dashed.
ax.clabel(CS, fontsize=9, inline=True)
ax.set_title('Single color - negative contours solid')

With this PR

fig2, ax2 = plt.subplots()
CS = ax2.contour(X, Y, Z, 6, colors='k', negative_linestyles='solid')
ax2.clabel(CS, fontsize=9, inline=True)
ax2.set_title('Single color - negative contours solid')

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

Comment thread lib/matplotlib/contour.py Outdated
Comment on lines +1760 to +1761
negative_linestyles : None or str, optional
{'solid', 'dashed', 'dashdot', 'dotted'}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
negative_linestyles : None or str, optional
{'solid', 'dashed', 'dashdot', 'dotted'}
negative_linestyles : {*None*, 'solid', 'dashed', 'dashdot', 'dotted'}, \
optional

(or where ever the line should break.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I went ahead and made this exact change. It matches linestyles formatting... I'm not sure where I saw the formatting I initially had.

jklymak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This looks good to me, and useful.

tacaswell added this to the v3.6.0 milestone Jun 24, 2022
tacaswell merged commit dff87ce into matplotlib:main Jun 24, 2022
QuLogic mentioned this pull request Sep 9, 2022
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

[ENH]: contour kwarg for negative_linestyle

5 participants


Back | FazBrowse Home | New Git URL