Skip to content

Log Colorbar minorticks_off reverted if ticks set... #13339

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

Closed
jklymak opened this issue Feb 1, 2019 · 7 comments
Closed

Log Colorbar minorticks_off reverted if ticks set... #13339

jklymak opened this issue Feb 1, 2019 · 7 comments
Milestone

Comments

@jklymak
Copy link
Member

jklymak commented Feb 1, 2019

Posted by @LevN0

Apologies if not the right place. This PR has the following side effect:

fig, ax = plt.subplots()

data = np.clip(randn(250, 250)*1000, 0, 1000)

cax = ax.imshow(data, norm=mpl.colors.LogNorm(vmin=1, vmax=1000))
cbar = fig.colorbar(cax, format='%d')

cbar.minorticks_off()
cbar.set_ticks([5, 10, 100])

plt.show()

Prior to this PR, minor ticks would remain off after set_ticks when they had been turned off. After this PR, they come back on.

Originally posted by @LevN0 in #12909 (comment)

@LevN0
Copy link
Contributor

LevN0 commented Feb 1, 2019

Actually do not think connected to that PR, not sure why I thought it was.

The cause is straight forward when looking at the code (set_ticks calls update_ticks, which sets minor ticks on for LogNorm). Post #13234, if it were accepted in current form, the turning on of minor ticks for LogNorm could be moved to new _reset_locator_formatter_scale, though not sure if that introduces any new issues.

@jklymak jklymak changed the title Apologies if not the right place. This PR has the following side effect: Log Colorbar minorticks_off reverted if ticks set... Feb 1, 2019
@jklymak
Copy link
Member Author

jklymak commented Feb 1, 2019

Can you give it a try and run the tests, and submit a PR if that is a reasonable solution? Seems you found something that works, so feel free to give it a try...

OTOH, did you test if the same thing happens for log-axes on a normal axes instead of a colorbar? The point of the colorbar changes recently were to make the colorbar behave more like a normal axis, so, anything we can do to further that end is welcome.

@tacaswell tacaswell added this to the v3.1 milestone Feb 1, 2019
@LevN0
Copy link
Contributor

LevN0 commented Feb 1, 2019

If the following is sufficient to test normal axes, then the same issue does not appear for them:

t = np.arange(0.01, 20.0, 0.01)

ax = plt.subplot(111)
plt.loglog(t, 20*np.exp(-t/10.0), basex=2)

ax.minorticks_off()
ax.set_yticks([3, 4, 6, 10, 20])

plt.show()

I am actually not sure how to submit a PR when the per-requisite PR has not been merged.

@jklymak
Copy link
Member Author

jklymak commented Feb 1, 2019

I think the problem is in master w/o #13234 right? Or would your proposed change stomp on #13234?

@LevN0
Copy link
Contributor

LevN0 commented Feb 1, 2019

Problem is in master w/o #13234. However the proposed fix needs behavior/function introduced by #13234.

@jklymak
Copy link
Member Author

jklymak commented Feb 1, 2019

Right - may as well wait for #13234 to go in, though you can make a PR against that branch and then rebas when its merged, its a bit fragile to do that.

@jklymak
Copy link
Member Author

jklymak commented Feb 2, 2019

@LevN0 #13234 is merged, so if you want to talk a crack at fixing this, that'd be great. If you can't get to it, ping me and I can probably do it. Thanks!

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

No branches or pull requests

3 participants