Hi All,

Caveat: new user to both Python and Veusz

I'm looking at different ways to use Python to work around some plotting 
limitations in a commercial software package I use, where I would like to write 
out many 2D grid datasets and post-process them via a python script.  To that 
end, I constructed the python script below.  When I run the script I don't get 
any error messages, but I don't get a plot of the data either.  What I end up 
with is an empty plot window with axes going from 0 to 1.  For reference, the 
example provided in the documentation does run without any problems.  Any 
suggestions regarding what I'm doing wrong?


import veusembed as veusz
import numpy as np

def gauss(xVal,yVal):
    hw      = 2.5
    hw2     = 2.5 * 2.5
    r2      = xVal * xVal + yVal * yVal
    return np.exp(-r2/(2 * hw2))

# axis ranges
x = np.linspace(-5,5,101)
y = x

# calc gaussian
dats=np.zeros((len(x),len(y)))
for ii in range(len(x)):
    for jj in range(len(y)):
        #print(ii,',',jj)
        dats[ii,jj]=gauss(x[ii],y[jj])

# plotting
vfig = veusz.Embedded('Grid Plot')
vfig.Add('page',name='gbPage',autoadd=False)
vfig.To('gbPage')
vfig.Add('graph',name='gbGraph',autoadd=False)
vfig.To('gbGraph')
vfig.Add('axis',name='x',autoadd=False)
vfig.Add('axis',name='y',autoadd=False)
vfig.To('y')
vfig.Set('direction','vertical')
vfig.To('..')
vfig.Add('contour',name='gbContour',autoadd=False)
vfig.To('gbContour')
vfig.SetData2D('grid', dats, xrange=(-5,5), yrange=(-5,5))
vfig.Set('numLevels', 31)


_______________________________________________
Veusz-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/veusz-discuss

Répondre à