Skip to content

incorrect default limits 'log' scale depending on order of scatter #11198

Closed

Description

@lboogaard

Bug report

Bug summary

After setting scale to 'log' the default limits can cut off datapoints depending on the order of plotting.

Note: calling set_xscale/set_yscale before calling scatter does not reproduce this bug.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

# smallest span
x1 = np.array([1, 10])
y1 = np.array([10, 1])

# largest span
x2 = np.array([0.1, 100])
y2 = np.array([100, 0.1])

fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2,2, figsize=(8,8))

ax1.scatter(x1, y1)
ax1.scatter(x2, y2)
ax1.set_title('linear; smallest span first', color='g')

ax2.scatter(x1, y1)
ax2.scatter(x2, y2)
ax2.set_xscale('log')
ax2.set_yscale('log')
ax2.set_title('log; smallest span first', color='r')

ax3.scatter(x2, y2)
ax3.scatter(x1, y1)
ax3.set_title('linear; largest span first', color='g')

ax4.scatter(x2, y2)
ax4.scatter(x1, y1)
ax4.set_xscale('log')
ax4.set_yscale('log')
ax4.set_title('log; largest span first', color='g')

Outcome
log-order-bug

Matplotlib version

  • Matplotlib version: 2.2.2
  • Matplotlib backend: MacOSX
  • Python version: 2.7.14 and 3.6.4

Activity

  1. ImportanceOfBeingErnest commented on May 8, 2018

    @ImportanceOfBeingErnest
    Member

    Does this depend on plotting a scatter or would it occur for a line plot as well?

  2. lboogaard commented on May 8, 2018

    @lboogaard
    ContributorAuthor

    It doesn't occur for a line plot; calling ax.plot instead of ax.scatter rescales correctly.

  3. ImportanceOfBeingErnest commented on May 8, 2018

    @ImportanceOfBeingErnest
    Member

    I think this is a duplicate of #6915 and the cause is No.2 in #7413.
    ... which is still unsolved though.

  4. anntzer commented on May 8, 2018

    @anntzer
    Contributor

    I agree it's a duplicate (for an important issue).

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