X Tutup
Skip to content

fill_between() not working properly #6650

@avipersin

Description

@avipersin

Matplotlib 1.5.1
Python 3.4
Anaconda 4.0.1

import matplotlib.pyplot as plt
import numpy as np

xs = [1950.04, 1950.29, 1950.54, 1950.79, 1951.04, 1951.29, 1951.54, 1951.79, 1952.04, 1952.29, 1952.54, 1952.79, 1953.04, 1953.29, 1953.54, 1953.79, 1954.04, 1954.29, 1954.54, 1954.79, 1955.04, 1955.29, 1955.54, 1955.79, 1956.04, 1956.29, 1956.54, 1956.79, 1957.04, 1957.29, 1957.54, 1957.79, 1958.04, 1958.29, 1958.54]
ys = [-1.46, -1.17, -0.73, -0.7, -0.98, 0.14, 0.36, 0.71, 0.33, 0.44, -0.06, 0.03, 0.41, 0.66, 0.62, 0.62, 0.55, -0.39, -0.62, -0.75, -0.68, -0.71, -0.64, -1.52, -0.97, -0.47, -0.52, -0.57, -0.34, 0.59, 1.02, 1.05, 1.6, 0.87, 0.44]

plt.plot(xs, ys)
plt.fill_between(xs, 0, ys, where=np.asarray(ys) > 0, facecolor='red')
plt.savefig("fill_between.png")
plt.show()

fill_between() is not properly filling along the line when y > 0. The image below illustrates the problem.

fill_between

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup