Created
May 21, 2017 14:16
-
-
Save Atlas7/6371d6a83aa72c15b3e160adcffcdbb4 to your computer and use it in GitHub Desktop.
sample_jupyter_notebook_plot.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# clean up kernel | |
%reset -f | |
# This is a bit of magic to make matplotlib figures appear inline in the notebook | |
# rather than in a new window. | |
%matplotlib inline | |
# Some more magic so that the notebook will reload external python modules; | |
# see http://stackoverflow.com/questions/1907993/autoreload-of-modules-in-ipython | |
%load_ext autoreload | |
%autoreload 2 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
n = 256 | |
X = np.linspace(-np.pi, np.pi, n, endpoint=True) | |
Y = np.sin(2 * X) | |
plt.axes([0.025, 0.025, 0.95, 0.95]) | |
plt.plot(X, Y + 1, color='blue', alpha=1.00) | |
plt.fill_between(X, 1, Y + 1, color='blue', alpha=.25) | |
plt.plot(X, Y - 1, color='blue', alpha=1.00) | |
plt.fill_between(X, -1, Y - 1, (Y - 1) > -1, color='blue', alpha=.25) | |
plt.fill_between(X, -1, Y - 1, (Y - 1) < -1, color='red', alpha=.25) | |
plt.xlim(-np.pi, np.pi) | |
plt.xticks(()) | |
plt.ylim(-2.5, 2.5) | |
plt.yticks(()) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use in this Stackoverflow