Skip to content

ENH: add zorder kwarg to contour clabel (and a better default value for zorder)#16329

Merged
jklymak merged 4 commits intomatplotlib:masterfrom
pharshalp:clabel_zorder
Jan 27, 2020
Merged

ENH: add zorder kwarg to contour clabel (and a better default value for zorder)#16329
jklymak merged 4 commits intomatplotlib:masterfrom
pharshalp:clabel_zorder

Conversation

@pharshalp
Copy link
Contributor

@pharshalp pharshalp commented Jan 26, 2020

PR Summary

Fixes #7957

import matplotlib.pyplot as plt
import numpy as np

x, y = np.meshgrid(np.arange(0, 10), np.arange(0, 10))
z = np.max(np.dstack([abs(x), abs(y)]), 2)

fig, ax = plt.subplots(figsize=(3.5, 3), constrained_layout=True)
ax.contour(x, y, z, colors='0.50', linewidths=8.0, zorder=10) 
cs = ax.contour(x, y, z, zorder=11)
clabels = cs.clabel(colors='k', zorder=12)
# currently the zorder kwarg is not supported
# hence the following lines are required to set the zorder 
# for the contour labels' text manually.
# for clabel in clabels: 
#    clabel.set_zorder(12)
fig.savefig('clabel_zorder.png')

clabel_zorder_after

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • [NA] 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)
  • [NA] Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@pharshalp pharshalp changed the title add zorder arg to clabel add zorder kwarg to clabel Jan 26, 2020
@pharshalp pharshalp marked this pull request as ready for review January 26, 2020 03:13
@pharshalp pharshalp changed the title add zorder kwarg to clabel ENH: add zorder kwarg to contour clabel Jan 26, 2020
anntzer
anntzer previously approved these changes Jan 26, 2020
Copy link
Contributor

@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

post-ci

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.

I think you need to document this new kwarg as well since clabel doesn't automatically pass down kwargs?

@pharshalp
Copy link
Contributor Author

I think you need to document this new kwarg as well since clabel doesn't automatically pass down kwargs?

done

@pharshalp pharshalp changed the title ENH: add zorder kwarg to contour clabel ENH: add zorder kwarg to contour clabel (and a better default value for zorder) Jan 26, 2020
@anntzer anntzer dismissed their stale review January 27, 2020 06:25

confused by zorder choices...

Copy link
Contributor

@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

postci

@jklymak jklymak added this to the v3.3.0 milestone Jan 27, 2020
@jklymak jklymak merged commit 34aa790 into matplotlib:master Jan 27, 2020
@jklymak
Copy link
Member

jklymak commented Jan 27, 2020

Thanks a lot @pharshalp !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clabel not respecting zorder parameter

3 participants