Skip to content

Instantly share code, notes, and snippets.

@erikaris
Last active November 2, 2017 13:43
Show Gist options
  • Save erikaris/76c23557cdf23313f2532d6a9e9b45a4 to your computer and use it in GitHub Desktop.
Save erikaris/76c23557cdf23313f2532d6a9e9b45a4 to your computer and use it in GitHub Desktop.
%matplotlib notebook
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0.0, 2, 0.01)
y1 = np.sin(2 * np.pi * x)
y2 = 1.2 * np.sin(4 * np.pi * x)
fig, (ax, ax1) = plt.subplots(2, 1, sharex=True)
ax.plot(x, y1, x, y2, color='black')
ax.fill_between(x, y1, y2, where=y2 >= y1, facecolor='green', interpolate=True)
ax.fill_between(x, y1, y2, where=y2 <= y1, facecolor='red', interpolate=True)
ax.set_title('fill between where')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment