Skip to content

negative_linestyles kwarg in contour.py #23266

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 2 commits into from
Jun 24, 2022

Conversation

andrew-fennell
Copy link
Contributor

@andrew-fennell andrew-fennell commented Jun 14, 2022

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 on lines 1760 to 1761
negative_linestyles : None or str, optional
{'solid', 'dashed', 'dashdot', 'dotted'}
Copy link
Member

Choose a reason for hiding this comment

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

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
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

This looks good to me, and useful.

@tacaswell tacaswell added this to the v3.6.0 milestone Jun 24, 2022
@tacaswell tacaswell merged commit dff87ce into matplotlib:main Jun 24, 2022
@QuLogic QuLogic mentioned this pull request Sep 9, 2022
2 tasks
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