Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ax.fill_between broken for log scale and values below zero #9457

Closed
@hsandmeyer

Description

@hsandmeyer

ax.fill broken for log scale and values below zero

When using ax.fill_between in log scale plots with y-values below zero, the result looks broken and areas are filled that should not be filled

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt
xdata=np.arange(0,10,0.01)
ydata = np.exp(-xdata)
edata = 0.2*(10-xdata)*np.cos(5*xdata)*np.exp(-xdata)

fig, ax = plt.subplots()
plt.yscale('log')

ax.fill_between(xdata, ydata - edata, ydata + edata)

plt.savefig("test.png")

Actual outcome

broken

Expected outcome

correct
The correct example has been generated with matplotlib-2.0.2-1

Probably related: #8623
How to deal with invalid values in log scale plots is certainly a matter of definition. However, it should never happen that areas are filled that should not be filled, as it is the case in the example above.

Matplotlib version

  • Operating system: arch linux
  • Matplotlib version: 2.1.0-1
  • Matplotlib backend: Qt5Agg
  • Python version: 3.6.2
  • Other libraries: numpy version: 1.13.3-1

Everything installed using the package manager of arch linux.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions