Question #452868 on Yade changed:
https://answers.launchpad.net/yade/+question/452868

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hi Weimin,
after a quick look, I did not find any solution (although I am not very
familiar with matplotlib). A dirty workaround is to create a new simulation
with bodies with swapped coordinates and swapped data and plot them:

######################################################
from yade import post2d
import pylab
import random
r = random.random

sphs = ([sphere((-.5+r(),-.5+r(),-1+2*r()),.05) for i in xrange(20)]) #
some random particles
O.bodies.append(sphs)

flattener = post2d.AxisFlatten(axis=1)
extractSomething = lambda b: 2*b.state.pos # extract something
extractSomething2 = lambda b: b.data # b.data is just temporary variable to
save the swapped data

# normal process
pylab.figure()
post2d.plot(post2d.data(extractSomething,flattener))

# get and swap positions of particles
poss = [b.state.pos for b in O.bodies]
poss = [Vector3(p[2],p[1],p[0]) for p in poss]
# get and swap data
data = [extractSomething(b) for b in O.bodies]
data = [Vector3(d[2],d[1],d[0]) for d in data]

O.switchScene() # not to indluence current simulation
# add particles with swapped coordinates
O.bodies.append([sphere(p,.05) for p in poss])
# assign them swapped data
for b in O.bodies:
  b.data = data[b.id]

pylab.figure()
post2d.plot(post2d.data(extractSomething2,flattener))

O.switchScene() # back to the original simulation

pylab.show()
######################################################

cheers
Jan

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to     : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to