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:

enter image description here

i expected series of concentric squares, this:

enter image description here

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() 

output

hth


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -