matplotlib - Making snapshot plots using python -


i have dynamic simulation trying visualise in paper writing.

i take 'snapshots' of dynamics progress on time, , superimpose of them on same canvas, plotted against time (for each snapshot).

similar (walking mechanism):

enter image description here

for completeness; snapshots taken @ regular interval, predefined frequency. emulate.

this answer might need iterations improve since still not clear how model looks, kind of data get, etc. below attempt #1 plots dynamic (drunk stick figure) system in time/space.

import matplotlib.pylab pl import numpy np  pl.close('all')  y = np.array([2,1,0]) # y-location of hips,knees,feet x = np.zeros((2,3))   # x-coordinates of both legs  # plot while model runs: pl.figure() pl.title('drunk stick figure', loc='left') pl.xlabel('x') pl.ylabel('y')  # model: t in range(10):     x[:,0] = t  # start (top of legs) progress in x in time     x[:,1] = x[:,0] + np.random.random(2)  # random location knees     x[:,2] = x[:,0] + np.random.random(2)  # random location feet      pl.plot(x[0,:], y[:], color='k')     pl.plot(x[1,:], y[:], color='r')      # or, if want plot every nth (lets second) step:     # if (t % 2 == 0):     #     pl.plot(..) 

enter image description here

in case plot updated while model runs, of course changed e.g. saving data , plotting them in similar loop afterwards.


Comments

Popular posts from this blog

many to many - Django Rest Framework ManyToMany filter multiple values -

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

Java Entity Manager - JSON reader was expecting a value but found 'db' -