Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FIX: allow secondary axes minor locators to be set#14447

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

jklymak
Copy link
Member

PR Summary

We set the scale forsecondary_axis for each draw in case the parent scale has changed (i.e. from linear to log), but this means that we can't set the locators and formatters for the secondary axis. This change keeps track of the parent scale and only resets the locators and formatters if the parent scale changes.

Closes#14443

importmatplotlib.pyplotaspltimportnumpyasnpimportmatplotlib.tickerasmtickerfig,ax=plt.subplots(constrained_layout=True)x=np.arange(0,360,1)y=np.sin(2*x*np.pi/180)ax.plot(x,y)ax.set_xlabel('angle [degrees]')ax.set_ylabel('signal')ax.set_title('Sine wave')defdeg2rad(x):returnx*np.pi/180defrad2deg(x):returnx*180/np.pisecax=ax.secondary_xaxis('top',functions=(deg2rad,rad2deg))secax.set_xlabel('angle [rad]')ax.minorticks_on()secax.minorticks_on()plt.show()

now works as expected...

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 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

@jklymakjklymak marked this pull request as ready for reviewJune 4, 2019 21:20
@tacaswelltacaswell added this to thev3.2.0 milestoneJun 8, 2019
@@ -272,6 +273,11 @@ def _set_scale(self):
if self._orientation == 'y':
pscale = self._parent.yaxis.get_scale()
set_scale = self.set_yscale
if pscale == self._parentscale:
Copy link
Member

Choose a reason for hiding this comment

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

do we want== oris here?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's ==, get_scale returns a string. Well really we should retrieve the scale object rather than a scale string, but that's a separate issue...

Copy link
Member

@tacaswelltacaswell left a comment

Choose a reason for hiding this comment

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

One minor comment, but otherwise 👍

@tacaswell
Copy link
Member

Milestoned as 3.2 as a new feature, but I also see the case that this is a bug-fix. I leave to@jklymak to decide.

@jklymak can self-merge this after re-milestoning.

@anntzer
Copy link
Contributor

Merging as 3.2, but@jklymak can backport to 3.1 if he wants :)

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

@tacaswelltacaswelltacaswell approved these changes

@anntzeranntzeranntzer approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.2.0
Development

Successfully merging this pull request may close these issues.

Secondary axis does not show minor ticks.
4 participants
@jklymak@tacaswell@anntzer@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp