Last active
February 12, 2018 20:22
-
-
Save mpilosov/736438173407fc8a26488eeeb567c3b0 to your computer and use it in GitHub Desktop.
plotting non-functions
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
# something that doesn't pass the vertical line test, comes to us unordered.... we want to piecewise-interpolate. | |
import numpy as np | |
# partition our data so that each segment DOES pass the vertical line test. | |
c = np.where(a[:,1] >= 0.5)[0] | |
d = np.where(a[:,1] < 0.5)[0] | |
above = a[c,:] # copies of a | |
below = a[d,:] | |
print(above) | |
print(below) | |
# sort them | |
ab = np.argsort(above[:,0]) | |
be = np.argsort(below[:,0]) | |
# notice how the sorting works. | |
print(above[ab]) | |
print(below[be]) | |
plt.scatter(a[:,0], a[:,1]) | |
plt.plot(above[ab,0], above[ab,1]) | |
plt.plot(below[be,0], below[be,1]) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment