Skip to content

symlog + minor ticks = exception #6967

Closed

Description

@LevN0

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()

Activity

  1. added this to the milestone on Aug 23, 2016
  2. tacaswell commented on Aug 24, 2016

    @tacaswell
    Member

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

  3. dncnwtts commented on Sep 23, 2016

    @dncnwtts

    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.

  4. modified the milestones: , on May 3, 2017
  5. tacaswell commented on May 15, 2017

    @tacaswell
    Member

    closed by #8367

  6. modified the milestones: v2.0.1, on May 15, 2017
  7. zhangt58 commented on Oct 25, 2018

    @zhangt58

    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())
  8. guido-granda commented on Mar 8, 2021

    @guido-granda

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions