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

Skip to content

Add labels parameter to set_ticks() #20047

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
May 14, 2021

Conversation

timhoffm
Copy link
Member

@timhoffm timhoffm commented Apr 22, 2021

PR Summary

As proposed in #18848 (comment) and discussed on today's dev call.

Closes #18848, #19016.

kwargs: I've added kwargs for text properties. While this makes the function do a lot (borderline of too much), it is necessary if we want a full replacement of set_ticklabels(labels, **text_properties).
One can argue that this is actually too much, in which case we'd have to advertise

# Replace
set_ticks(locs)
set_ticklabels(labels, **text_properties)
# by
set_ticks(locs, labels)
tick_params(**text_properties)

Return value: set_ticks() has an undocumented return value (list of the Tick instances). While plt.xticks() returns a tuple (locs, labels) (list of Ticks and list of Texts), I don't want to do this here. First, I don't think the setter should return anything at all (but that's how it is for now and deprecating that is probably not worth it). Second, since labels are optional, I'm not even sure if we would want to give the texts only if labels is not None.

@timhoffm timhoffm added this to the v3.5.0 milestone Apr 22, 2021
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.

looks good. Prob needs API note, or what's new...

@timhoffm timhoffm force-pushed the set_ticks-labels branch 2 times, most recently from 5c3983f to ddee963 Compare April 24, 2021 21:16
@jklymak jklymak requested a review from anntzer May 3, 2021 14:30
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.

approving modulo addressing (or rejecting) the two comments above.

@timhoffm timhoffm force-pushed the set_ticks-labels branch from 5f54d29 to ed54043 Compare May 5, 2021 20:06
@jklymak
Copy link
Member

jklymak commented May 10, 2021

I think the doc error is real:

/home/circleci/project/lib/matplotlib/axis.py:docstring of matplotlib.axis.Axis.set_ticklabels:10: WARNING: more than one target found for cross-reference 'FixedLocator': mpl_toolkits.axisartist.grid_finder.FixedLocator, matplotlib.ticker.FixedLocator

@jklymak jklymak marked this pull request as draft May 10, 2021 22:24
@timhoffm timhoffm force-pushed the set_ticks-labels branch from ed54043 to 9e5b1d6 Compare May 13, 2021 23:47
@timhoffm timhoffm marked this pull request as ready for review May 14, 2021 00:53
@tacaswell tacaswell merged commit cfc6b1f into matplotlib:master May 14, 2021
@timhoffm timhoffm deleted the set_ticks-labels branch May 14, 2021 07:52
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.

Setting xticklabels causes warning related to FixedFormatter
5 participants