Skip to content

Instantly share code, notes, and snippets.

@jchuahtacc
Created June 9, 2017 20:13
Show Gist options
  • Save jchuahtacc/6e25a355bd04477e83f949e3c7383b60 to your computer and use it in GitHub Desktop.
Save jchuahtacc/6e25a355bd04477e83f949e3c7383b60 to your computer and use it in GitHub Desktop.
segments = 5
accels = [ 0, 1, 2, 3, 4 ]
vs = [ 0, 0.5, 1, 1.5, 2 ]
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
ts = [ np.linspace(t * 100, t * 100 + 99, 10) for t in range(5)]
ys = [ 0.5 * np.square(ts[i]) * accels[i] + ts[i] * vs[i] for i in range(5) ]
fig = plt.figure()
ax1 = fig.add_subplot(111)
for i in range(5):
ax1.scatter(ts[i], ys[i])
plt.show()
@dmcdougall
Copy link

Here's what I had:

import numpy as np
import matplotlib.pyplot as plt
from ipywidgets import interact

t = np.arange(0, 1, 0.01)

v = t
s = 0.5 * t * t

plt.figure(1)

def pltgraphs(d, a):
    plt.subplot(311)
    plt.plot(t,d*0.5*a*t*t)
    plt.gca().set_ylim(0, 25)
    plt.subplot(312)
    plt.plot(t,d*a*t)
    plt.subplot(313)
    plt.plot(t,[d*a]*len(t))
    plt.show()

interact(pltgraphs,d=(0,10,0.01),a=(0,10,0.01))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment