Help with a Bounce Ball plot - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Help with a Bounce Ball plot (/thread-9836.html) |
Help with a Bounce Ball plot - nicluc - Apr-30-2018 I cannot figure out why my plot isn't working. I'm trying to graph a plot that starts at 3ft vertically and goes for 3 seconds. I also do not know how to curve my lines. Any help would be appreciated. td=0 vd=0 HorzPosition=0 VertPosition=3 HorzP=[] VertP=[] Timeiter=0 b=1 td=((2*3)/32)**(0.5) vd=(td)*32 print("First Bounce") print("Time Down to Bounce") print(td) print("Velocity Down at Bounce") print(vd) et=td Timex=[] Horz = [] Horz.append(td) print("At Bounce number") print(b) Timex.append(td) while b<=64: vu=(vd)*0.75 tu=(vu)/32 Horz.append(tu) print("Time up to Apex") print(tu) print("Velocity up to Apex") print(vu) et+= tu Timex.append(et) print("Elapsed Time") print(et) td=tu Horz.append(td) vd=vu print("Time down to next bounce") print(td) print("Velocity down to next Bounce") print(vd) et = et+td Timex.append(et) print("Elapsed Time") print(et) print("At Bounce number") print(b+1) vu=(vd)*0.75 tu=(vu)/32 Horz.append(tu) print("Time up to Apex") print(tu) print("Velocity up to Apex") print(vu) et = et+tu Timex.append(et) print("Elapsed Time") print(et) td=tu Horz.append(td) vd=vu print("Time down to next bounce") print(td) print("Velocity down to next Bounce") print(vd) et = et+td Timex.append(et) print("Elapsed Time") print(et) b+=1 print("Timex") print(Timex) print("Horz") print(Horz) print("Elapsed Time") print(et) import matplotlib.pyplot as plt plt.plot(Timex,Horz) RE: Help with a Bounce Ball plot - j.crater - Apr-30-2018 Please put your code in Python code tags, you can find help here. RE: Help with a Bounce Ball plot - micseydel - Apr-30-2018 I went ahead and made the edit that j.crater suggested. I suspect you need to plt.show(), but I'm in a rush at the moment and don't have time to play with it. RE: Help with a Bounce Ball plot - killerrex - Apr-30-2018 (Apr-30-2018, 06:25 PM)micseydel Wrote: I suspect you need to plt.show(), but I'm in a rush at the moment and don't have time to play with it.If I add the plt.show() it shows something... @nicluc if you want to plot smooth lines you have 3 options: - The easy one, add more intermediate points - Interpolate the values you have obtained with scipy.interpolate to add more points - The hard way: Use bezier curves and patches. Not recommended except if you know what you are doing... Be careful with the option to interpolate... you might need to add at least 2 intermediate points in each arc of the bounce or the interpolation will look silly. Also interpolating by segments -leaving out of the interpolation interval the bouncing points- help to avoid strange border effects. |