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

Skip to content

fill_between incorrect with log y-axis and value 0 #8623

Closed
@cdeil

Description

@cdeil

fill_between doesn't give the result I expect if using a log y-axis and having a value of 0 in the y1 array.

Example:

%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt

x = np.array([1, 2, 3, 4, 5])
y1 = np.array([9, 2, 8, 3, 0])
y2 = np.array([10, 10, 10, 10, 10])

plt.plot(x, y1, lw=3, color='green')
plt.plot(x, y2, lw=3, color='red')
plt.fill_between(x, y1, y2)
plt.loglog()

Actual outcome:

The polygon created by fill_between somehow connects the last and first point, resulting in a completely incorrect patch:

image

Expected outcome

I was expecting / hoping that the band would be filled correctly and simply clipped (i.e. the result I get when changing the last y1 value from 0 to e.g. 1e-10). In the plot, the blue fill should be between the red and green line.

Matplotlib version

This is with Matplotlib 2.0.0.
(on Macports, but I don't think that matters)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions