Skip to content

plot.scatter: negative or null values lead to strange behavior on log scale #11898

Closed
@ivankeller

Description

@ivankeller

Bug report

Related issues have already been reported but I think a simpler case is worth mentioning:

Bug summary

With negative or null values, log scale fails (although it does not crashes) discarding (masking) more points than the ones corresponding to the invalid negative or null values. At least a WARNING would be welcome.

Code for reproduction

Normal behavior: only positive values in y :

x = [1, 2, 3, 4]
y = [1, 10, 50, 100]
plt.scatter(x, y)
plt.yscale('log')

Actual outcome:
image

Bug: with value 0 in y (idem with negative values):

x = [1, 2, 3, 4]
y = [0, 10, 50, 100]
plt.scatter(x, y)
plt.yscale('log')

Actual outcome: only the last point is displayed.

image

Expected outcome
I understand that default behavior is masking of non positive values. But it seems that more values are masked. I tried chaging parameter nonposy : plt.yscale('log', nonposy='clip') but the behavior is the same.
At least a WARNING should be displayed about presence of negative or null values not compatible with log scale.

Matplotlib version

  • Operating system: Ubuntu 14.04.3 LTS
  • Matplotlib version: 2.2.2
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline
  • Python version: 3.6.5
  • Jupyter version (if applicable): 5.5.0
  • Other libraries:

matplotlib installed from conda default.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions