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

Skip to content

symlog + minor ticks = exception #6967

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
LevN0 opened this issue Aug 23, 2016 · 5 comments
Closed

symlog + minor ticks = exception #6967

LevN0 opened this issue Aug 23, 2016 · 5 comments

Comments

@LevN0
Copy link
Contributor

LevN0 commented Aug 23, 2016

Present in 1.5.1 and on 2.0.0b3, as well as master I think.

Enabling minor ticks via minorticks_on and having scale set to symlog raises an exception. In minorticks_on, the input passed to SymmetricalLogLocator is base and subs, but SymmetricalLogLocator is expecting transform and subs. Calling self._transform.base, when self._transform is a base (a float) causes exception,

...
File "C:\Python27_numpy\lib\site-packages\matplotlib\axis.py", line 900, in iter_ticks
minorLocs = self.minor.locator()
File "C:\Python27_numpy\lib\site-packages\matplotlib\ticker.py", line 1662, in call
return self.tick_values(vmin, vmax)
File "C:\Python27_numpy\lib\site-packages\matplotlib\ticker.py", line 1665, in tick_values
b = self._transform.base
AttributeError: 'float' object has no attribute 'base'

Minimum code to reproduce,

import matplotlib.pyplot as plt

plt.plot([1,2,3,4])

ax = plt.gca()
ax.set_xscale('symlog')
ax.set_yscale('symlog')
ax.minorticks_on()

plt.show()
@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Aug 23, 2016
@tacaswell
Copy link
Member

This went in via a6716df from @Tillsten (but without a test). I am not sure this has ever actually worked.

@dncnwtts
Copy link

dncnwtts commented Sep 23, 2016

It seems like the issue has something to do with the way the SymmetricalLogLocator was implemented in the first place. The current implementation seems to explicitly exclude all ticks within the linear regime.

A custom solution described here seems to mostly solve the issue, which could be absorbed into the repository.

@QuLogic QuLogic modified the milestones: 2.0.1 (next bug fix release), 2.0.2 (next bug fix release) May 3, 2017
@tacaswell
Copy link
Member

closed by #8367

@QuLogic QuLogic modified the milestones: v2.0.1, 2.0.3 (next bug fix release) May 15, 2017
@zhangt58
Copy link

I've encountered this bug with 1.5.1 today, it's good to know the issue has been fixed in the newer release. While here is the trick to work around with version 1.5.1:

from matplotlib.ticker import AutoMinorLocator
from matplotlib.ticker import NullLocator
# turn minor ticks on
self.axes.xaxis.set_minor_locator(AutoMinorLocator())
self.axes.yaxis.set_minor_locator(AutoMinorLocator())
# turn minor ticks off
self.axes.xaxis.set_minor_locator(NullLocator())
self.axes.yaxis.set_minor_locator(NullLocator())

@guido-granda
Copy link

Hi,
I'm using matplotlib 3.3.4 and it looks like this usse is not fixed.

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

No branches or pull requests

6 participants