On Fri, 13 Jun 2008, washakie apparently wrote:
> DataDict={var1:(x1,y1),var2:(x2,y2),var3:(x3,y3)} ; where
> the x and y's are generally lists.
> Now that's nice, because I can cycle through the DataDict.keys() to batch
> plot, etc. But how can I convert the whole dict into
> a single array (assuming the lengths are all equal)?
Perhaps as below?
(Or the transpose.)
Alan Isaac
>>> x1,y1,x2,y2 =np.random.random((4,20))
>>> data = dict(var1=(x1,y1), var2=(x2,y2))
>>> a = np.c_[[d for xy in data.values() for d in xy]]
>>> a
array([[ 0.66613738, 0.39154179, 0.52399694, 0.54694366, 0.52103419,
0.06023608, 0.03752003, 0.14947236, 0.56515257, 0.03980963,
0.08809146, 0.27861545, 0.62107655, 0.01718959, 0.40346171,
0.8438409 , 0.84710117, 0.49979344, 0.93686618, 0.07087815],
[ 0.60181235, 0.1171198 , 0.40210686, 0.12248918, 0.73587718,
0.82907553, 0.04241232, 0.82834355, 0.89439919, 0.6477373 ,
0.88697623, 0.12711133, 0.08061116, 0.96609631, 0.69845226,
0.32363392, 0.05150339, 0.05108155, 0.66766576, 0.93701382],
[ 0.85075356, 0.12107294, 0.33732861, 0.22221564, 0.04249297,
0.54150883, 0.16414129, 0.93346553, 0.52176851, 0.24449367,
0.5526363 , 0.23359769, 0.40763005, 0.62820355, 0.70694987,
0.51204826, 0.15503887, 0.58975501, 0.32507773, 0.76876558],
[ 0.54390474, 0.30364361, 0.8469127 , 0.79118699, 0.88471469,
0.98490908, 0.03890524, 0.52584869, 0.08669779, 0.42734853,
0.17571326, 0.33677747, 0.3046382 , 0.17856421, 0.26186241,
0.2688219 , 0.97639377, 0.85320323, 0.84821184, 0.31592768]])
>>>
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users