Skip to content

ticklabels on log axes sometimes adds overwritten labels on top of existing ones  #8622

Closed

Description

@joezuntz

Bug report

For log axes setting the tick labels sometimes just adds new labels on top of the existing ones.

Code for reproduction

# Paste your code here
#Demonstration using the Agg backend, but this also happened for me with others.
import matplotlib
matplotlib.use('agg')
from matplotlib import pyplot as plt

# Some data I found that triggered this bug
x = [100,200,300,400,500,600,700,800,900,1000]
y = [ 1.7,  1.2,  0.98,  0.87,  0.76, 0.69,  0.62,  0.59,  0.56,  0.51]

#Only seems to happen for a log axis.  Same error if you do semilogy
plt.loglog(x, y)
#This does not seem to replace the old tick labels, just add new ones
plt.yticks([0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 2.0], ["0.5", "0.6", "0.7", "0.8", "0.9", "1.0", "2.0"])
plt.savefig("test.png")

Actual outcome

test

Expected outcome
Removal of the old tick labels as well as adding the new ones.

Matplotlib version

  • Operating System: MacOS Sierra 10.12.4
  • Matplotlib Version: 2.0.2
  • Python Version: 2.7.13
  • Jupyter Version (if applicable): N/A
  • Other Libraries: N/a

I used pip to install matplotlib and it downloaded matplotlib-2.0.2-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl

Activity

  1. joezuntz commented on May 15, 2017

    @joezuntz
    Author

    It looks like this can be solved by minorticks_off(), but I still think this should be considered a bug.

  2. tacaswell commented on May 15, 2017

    @tacaswell
    Member

    This change is documented at http://matplotlib.org/users/dflt_style_changes.html#tick-label-formatting .

    The coupling and special casing required to disable the minor ticks when the major ticks are non-default is a bit worrying (I do not see a clean way to do it), but am open to a PR to see what it would look like.

  3. added this to the milestone on May 15, 2017
  4. timhoffm commented on Jul 14, 2020

    @timhoffm
    Member

    Does not happen anymore as of master. Possibly closed by #13126.

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions