Skip to content

Trying to set_ylim(bottom=0) on a log scaled axis changes plot #7733

Closed

Description

@dstansby
import matplotlib.pyplot as plt

fig, axs = plt.subplots(2, 1)

axs[0].scatter(range(0, 4), [0, 1, 2, 3])
axs[1].scatter(range(0, 4), [0, 1, 2, 3])

axs[0].set_yscale('log')
axs[1].set_yscale('log')

axs[1].set_ylim(bottom=0)

plt.show()

This raises

/home/dstansby/matplotlib/lib/matplotlib/axes/_base.py:3174: UserWarning: Attempted to set non-positive ylimits for log-scale axis; invalid limits will be ignored.
  'Attempted to set non-positive ylimits for log-scale axis; '

However, the 2nd plot is changed by the set_ylim(bottom=0) call, and no data is visible.

figure_1

This is present on master.

Activity

  1. anntzer commented on Jan 13, 2017

    @anntzer
    Contributor

    See also the discussion at #7460 and the related PR #7744. It would be nice to have a consistent behavior in both cases (and possibly reuse the same code-path, if possible). As argued in #7460, I personally prefer the behavior of #7735 (treat invalid values as nan).

  2. added this to the milestone on Jan 13, 2017
  3. modified the milestones: , on Sep 24, 2017
  4. modified the milestones: , on Oct 9, 2017
  5. modified the milestones: , on Apr 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions