← Back to team overview

yade-users team mailing list archive

Re: [Question #676672]: list index out of range for plot.saveDataTxt ?

 

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

    Status: Open => Answered

Robert Caulk proposed the following answer:
Hello,

As shown in [1], if you want to use plot.saveDataTxt('',vars=()), you
need to add some variable data with plot.addData()[2]. Copied here for
clarity:

>>> from yade import plot
>>> from pprint import pprint
>>> plot.reset()
>>> plot.addData(a=1,b=11,c=21,d=31)  # add some data here
>>> plot.addData(a=2,b=12,c=22,d=32)
>>> pprint(plot.data)
{'a': [1, 2], 'b': [11, 12], 'c': [21, 22], 'd': [31, 32]}
>>> plot.saveDataTxt('/tmp/dataFile.txt.bz2',vars=('a','b','c'))
>>> import numpy
>>> d=numpy.genfromtxt('/tmp/dataFile.txt.bz2',dtype=None,names=True)
>>> d['a']
array([1, 2])
>>> d['b']
array([11, 12])

Cheers,

Robert

[1]https://yade-dem.org/doc/yade.plot.html#yade.plot.saveDataTxt
[2]https://yade-dem.org/doc/yade.plot.html#yade.plot.addData

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