<div dir="ltr"><div><div>Hello,<br><br></div><div>This might be simple, but I guess I am missing something here.<br></div>I have data file as follows:<br><br>2.1576318858 -1.8651195165 4.2333428278<br>2.1681875208 -1.9229968780 4.1989176884<br>2.3387636157 -2.0376253255 2.4460899122<br>2.1696565965 -2.6186941271 4.4172007912<br>2.0848862071 -2.1708981985 3.3404520962<br>2.0824347942 -1.9142798955 3.3629290206<br>2.0281685821 -1.8103363482 2.5446721669<br>2.3309993378 -1.8721153619 2.7006893016<br>2.0957461483 -1.5379071451 4.5228264441<br>2.2761376261 -2.5935979811 3.9231744717<br>.<br>.<br>.<br></div>(total of 200 lines)<br><div><div><br></div><div></div><div>Columns 1,2,3 corresponds to x,y,z axis data points.<br></div><div>This is not a continuous data. I wish to make a plot as a 2D with 3rd dimension (i.e z-axis data) as a color map with color bar on right hand side. <br></div><div><br>As a beginner, I tried to follow tutorial with some modification as follows: <a href="http://matplotlib.org/examples/pylab_examples/tricontour_vs_griddata.html">http://matplotlib.org/examples/pylab_examples/tricontour_vs_griddata.html</a><br><br></div><div># Read data from file:<br></div><div>fl1 = open('flooding-psiphi.dat','r').readlines()<br>xs = ys = zs = []<br>for line in fl1:<br>    line = line.split()<br>    xs.append(float(line[0]))<br>    ys.append(float(line[1]))<br>    zs.append(float(line[2]))<br><br>print xs[0], ys[0], zs[0]<br>xi = np.mgrid[-5.0:5.0:200j]<br>yi = np.mgrid[-5.0:5.0:200j]<br>zi = griddata((x, y), z, (xi, yi), method='cubic')<br>plt.subplot(221)<br><br>plt.contour(xi, yi, zi, 15, linewidths=0.5, colors='k')<br>plt.contourf(xi, yi, zi, 15, cmap=plt.cm.rainbow, norm=plt.Normalize(vmax=abs(zi).max(), vmin=-abs(zi).max()))<br>plt.colorbar()  # draw colorbar<br>plt.plot(x, y, 'ko', ms=3)<br>plt.xlim(-5, 5)<br>plt.ylim(-5, 5)<br>plt.title('griddata and contour (%d points, %d grid points)' %<br>          (npts, ngridx*ngridy))<br>#print ('griddata and contour seconds: %f' % (time.clock() - start))<br>plt.gcf().set_size_inches(6, 6)<br>plt.show()<br><br><br></div><div>However, I failed and getting long error as follows: <br><br>QH6154 qhull precision error: initial facet 1 is coplanar with the interior point<br>ERRONEOUS FACET:<br>- f1<br>    - flags: bottom simplicial upperDelaunay flipped<br>    - normal:    0.7071  -0.7071        0<br>    - offset:         -0<br>    - vertices: p600(v2) p452(v1) p304(v0)<br>    - neighboring facets: f2 f3 f4<br><br>While executing:  | qhull d Qz Qbb Qt<br>Options selected for Qhull 2010.1 2010/01/14:<br>  run-id 1531309415  delaunay  Qz-infinity-point  Qbbound-last  Qtriangulate<br>  _pre-merge  _zero-centrum  Pgood  _max-width 8.8  Error-roundoff 1.2e-14<br>  _one-merge 8.6e-14  _near-inside 4.3e-13  Visible-distance 2.5e-14<br>  U-coplanar-distance 2.5e-14  Width-outside 4.9e-14  _wide-facet 1.5e-13<br><br>precision problems (corrected unless 'Q0' or an error)<br>      2 flipped facets<br><br>The input to qhull appears to be less than 3 dimensional, or a<br>computation has overflowed.<br><br>Qhull could not construct a clearly convex simplex from points:<br>- p228(v3):   2.4   2.4   1.4<br>- p600(v2):   1.4   1.4   8.8<br>- p452(v1):   5.7   5.7     8<br>- p304(v0):  -3.1  -3.1   2.4<br><br>The center point is coplanar with a facet, or a vertex is coplanar<br>with a neighboring facet.  The maximum round off error for<br>computing distances is 1.2e-14.  The center point, facets and distances<br>to the center point are as follows:<br><br>center point    1.595    1.595    5.173<br><br>facet p600 p452 p304 distance=    0<br>facet p228 p452 p304 distance=    0<br>facet p228 p600 p304 distance=    0<br>facet p228 p600 p452 distance=    0<br><br>These points either have a maximum or minimum x-coordinate, or<br>they maximize the determinant for k coordinates.  Trial points<br>are first selected from points that maximize a coordinate.<br><br>The min and max coordinates for each dimension are:<br>  0:    -3.134     5.701  difference= 8.835<br>  1:    -3.134     5.701  difference= 8.835<br>  2:  -2.118e-22     8.835  difference= 8.835<br><br>If the input should be full dimensional, you have several options that<br>may determine an initial simplex:<br>  - use 'QJ'  to joggle the input and make it full dimensional<br>  - use 'QbB' to scale the points to the unit cube<br>  - use 'QR0' to randomly rotate the input for different maximum points<br>  - use 'Qs'  to search all points for the initial simplex<br>  - use 'En'  to specify a maximum roundoff error less than 1.2e-14.<br>  - trace execution with 'T3' to see the determinant for each point.<br><br>If the input is lower dimensional:<br>  - use 'QJ' to joggle the input and make it full dimensional<br>  - use 'Qbk:0Bk:0' to delete coordinate k from the input.  You should<br>    pick the coordinate with the least range.  The hull will have the<br>    correct topology.<br>  - determine the flat containing the points, rotate the points<br>    into a coordinate plane, and delete the other coordinates.<br>  - add one or more points to make the input full dimensional.<br>Traceback (most recent call last):<br>  File "./scatter.py", line 43, in <module><br>    zi = griddata((x, y), z, (xi, yi), method='linear')<br>  File "/usr/lib/python2.7/dist-packages/scipy/interpolate/ndgriddata.py", line 183, in griddata<br>    ip = LinearNDInterpolator(points, values, fill_value=fill_value)<br>  File "interpnd.pyx", line 192, in scipy.interpolate.interpnd.LinearNDInterpolator.__init__ (scipy/interpolate/interpnd.c:2598)<br>  File "qhull.pyx", line 948, in scipy.spatial.qhull.Delaunay.__init__ (scipy/spatial/qhull.c:4121)<br>  File "qhull.pyx", line 172, in scipy.spatial.qhull._construct_delaunay (scipy/spatial/qhull.c:1314)<br>RuntimeError: Qhull error<br><br><br></div><div>Could anyone help me to point out what exactly I am missing here. <br></div><div>I just wish to plot 2D map with color bar for Z-axis. <br><br></div><div>Thank you in advance.<br><br></div><div><div><div><br></div><div>-- DJ<br><br><br></div><div><br></div></div></div></div></div>