New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fill_between() not working properly #6650
Comments
I got around this by:
And because I also wanted to fill in below y=0, I did the opposite for the bottom. If fill_between() is not supposed to compute zero-crossings then this can be closed. |
Does passing the argument 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='Crimson', interpolate=True)
plt.fill_between(xs, 0, ys, where=np.asarray(ys) <= 0, facecolor='OliveDrab', interpolate=True)
plt.savefig("fill_between_w_interpolation.png")
plt.show() |
@afvincent Yes that works, thanks! I'll close this issue. |
@avipersin You're welcome. |
Matplotlib 1.5.1
Python 3.4
Anaconda 4.0.1
fill_between() is not properly filling along the line when y > 0. The image below illustrates the problem.
The text was updated successfully, but these errors were encountered: