views:

63

answers:

3

I have input values of x, y, z coordinates in the following format:

[-11.235865 5.866001 -4.604924]

[-11.262565 5.414276 -4.842384]

[-11.291885 5.418229 -4.849229]

[-11.235865 5.866001 -4.604924]

I want to draw polygons and succeeded with making a list of wx.point objects. But I need to plot floating point coordinates so I had to change it to point2D objects but DrawPolygon doesn't seem to understand floating points, which returns error message: TypeError: Expected a sequence of length-2 sequences or wxPoints.

I can't find anywhere in the API that can draw shapes based on point2D coordinates, could anyone tell me a function name will do the job?

Thanks

A: 

You just have to pass a list of XY tuples. In wxPython you don't have to explicitly use Point2D objects.

points = [
    (-11.235865, 5.866001),
    (-11.262565, 5.414276),
    (-11.291885, 5.418229),
    (-11.235865, 5.866001),
]

dc.DrawPolygon(points)
FogleBird
Tried above code, nothing shows up.
ttback
There are negative coordinates, you might be drawing off-screen. Also, did you set an appropriate Pen and Brush?
FogleBird
A: 

DC's only use integers. Try using Cairo or wx.GraphicsContext.

Steven Sproat
I gave gc a try last night. It has some promising results with DrawLines(), but the input format is very different. I am having a hard time to get the triangle drawn. I'll give it another try later today and see how it goes.
ttback
A: 

I think you should use matplotlib as it seems you need numerical data plotting.

leoluk