Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Autoscaling on log axis with negative data results in arbitrary limits. #10782

Closed
@ImportanceOfBeingErnest

Description

Bug report

Bug summary

Plotting negative values on a log scale is possible. However it changes the axis limits in a seemingly arbitrary way.

Code for reproduction

The following shows three scatter plots. Thex values
(1) are all positive
(2) contain one negative value
(3) have the negative value filtered out

import numpy as np; np.random.seed(1)import matplotlib.pyplot as pltx = np.random.rayleigh(100,400)y = np.random.rand(len(x))fig, (ax,ax2, ax3) = plt.subplots(nrows=3)ax.scatter(x,y)ax.set_xscale("log")ax.set_title("Scatter of all-positive values")ax2.scatter(x-2,y)ax2.set_xscale("log")ax2.set_title("Scatter with one negative value")cond = x-2 > 0ax3.scatter((x-2)[cond],y[cond])ax3.set_xscale("log")ax3.set_title("Expected scatter with one negative value")plt.tight_layout()plt.show()

Actual outcome

The second subplot, where the data contains a negative value, shows only part of the valid data, because the axis is autoscaled to some seemingly arbitrary region.

image

Expected outcome

The third subplot would be the expected outcome with the axis autoscaled to show all points.

One could also argue that plotting negative data on a log scale should not be supported at all, and that it should be the user's responsibility to make sure the data is positive. In that case however it would make sense to issue a warning instead of just plotting something arbitrary.

Matplotlib version

  • Operating system: Windows 8.1
  • Matplotlib version: 2.2
  • Matplotlib backend: any
  • Python version: 2.7.10

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp