Skip to content

Instantly share code, notes, and snippets.

@souri
Created March 18, 2015 09:28
Show Gist options
  • Save souri/bcfe75b3e6023b3692d0 to your computer and use it in GitHub Desktop.
Save souri/bcfe75b3e6023b3692d0 to your computer and use it in GitHub Desktop.
reetika's work
import math
import pprint
# import matplotlib.pyplot as plt
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from rotanimate import rotanimate
import numpy as np
# My custom float range
def xfrange(start, stop, step):
while start < stop:
yield start
start += step
colonrange = xfrange(150, 231, 0.05)
flexurerange = range(2, 16)
absurgerange = range(0, 1)
outputarray = []
for colonlength in colonrange:
for numflex in flexurerange:
for absurge in absurgerange:
logp = 8.851+ (-0.02161)*colonlength+(-2.34837)*absurge+(-0.44426)*numflex
exponentiated = math.e**logp
p = exponentiated/(1+exponentiated)
tempdata = [p, colonlength, numflex, absurge]
outputarray.append (tempdata)
print "Length: " + str(len(outputarray))
data = sorted(outputarray,key=lambda x: x[0])
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(data)
# for eachprediction in data:
# for eachvalue in eachprediction:
# print str(eachvalue) + ',',
# print '\n'
predictedp = []
inputcl = []
inputflex = []
for eachprediction in data:
if (eachprediction[0] > 0.0):
predictedp.append(eachprediction[0])
inputcl.append(eachprediction[1])
inputflex.append(eachprediction[2])
# plt.plot(predictedp, inputflex)
# plt.show()
fig = plt.figure()
ax = fig.gca(projection='3d')
#plot shit
ax.plot(inputcl, inputflex, predictedp, label='parametric curve')
ax.set_xlabel('length', fontsize=10)
ax.set_ylabel('numflex', fontsize=10)
ax.set_zlabel('p', fontsize=10)
plt.tick_params(axis='both', which='major', labelsize=6)
plt.tick_params(axis='both', which='minor', labelsize=6)
plt.show()
# create an animated gif (20ms between frames)
# angles = np.linspace(0,360,90)[:-1] # A list of 20 angles between 0 and 360
# rotanimate(ax, angles,'movie.gif',delay=20, width=8, height=6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment