Python/MatPlotLib yield odd, unexpected contours -
i'm trying contour plot function that's 0 @ 4 vertices of unit square, , 1 in middle of square. tried this:
import matplotlib.pyplot z = [[0,0,0], [1,0,0], [0,1,0], [1,1,0], [.5,.5,1]] cn = matplotlib.pyplot.contour(z) matplotlib.pyplot.show(cn) and got this:

i expected series of concentric squares, this:

which when do
listcontourplot[{{0,0,0}, {1,0,0}, {0,1,0}, {1,1,0}, {.5,.5,1}}, colorfunction -> (hue[#1]&)] in mathematica.
what did wrong?
edit: realize there's more 1 way draw contours given data. in case, series of concentric circles have been fine.
for non-meshed data, suggested in comments, want use tricontour function:
>>> import matplotlib.pyplot plt >>> z = [[0,0,0], [1,0,0], [0,1,0], [1,1,0], [.5,.5,1]] >>> x, y, z = zip(*z) >>> cn = plt.tricontourf(x, y, z) >>> plt.show() 
hth
Comments
Post a Comment