Created
June 27, 2013 17:12
-
-
Save addisoneee/5878325 to your computer and use it in GitHub Desktop.
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
import numpy as np | |
import matplotlib.pyplot as plt | |
def fun(x): | |
#This is where all the info on the function goes | |
if x < 28: | |
return 100000*x - 2721000 | |
else: | |
return 79000 | |
vfun = np.vectorize(fun) | |
x = np.linspace(27,29) | |
y = vfun(x) | |
plt.axis([27,29,-25000,90000]) | |
plt.plot(x,y,'-') | |
plt.show() |
Is there anyways to avoid the vertical lines between each sections of x?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
numpy's
piecewise
method also works well for plotingpiecewise functions