Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!hq-usenetpeers.eweka.nl!hq-usenetpeers.eweka.nl!bcyclone02.am1.xlned.com!bcyclone02.am1.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.189 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.62; '*S*': 0.00; 'tutorial': 0.03; 'error:': 0.07; 'skip:" 60': 0.07; '#print': 0.09; '(%d': 0.09; 'grid': 0.09; 'subject:plot': 0.09; 'colorbar': 0.16; 'columns': 0.16; 'coordinates': 0.16; 'corresponds': 0.16; 'data)': 0.16; 'dimension': 0.16; 'line.split()': 0.16; 'points:': 0.16; 'range.': 0.16; 'side.': 0.16; 'vertex': 0.16; 'x,y,z': 0.16; '\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0': 0.16; 'modification': 0.16; 'all,': 0.19; 'bit': 0.19; 'advance.': 0.19; 'appears': 0.22; 'input': 0.22; 'print': 0.22; 'error': 0.23; 'specify': 0.24; 'initial': 0.24; 'options': 0.25; '15,': 0.26; 'least': 0.26; 'tried': 0.27; 'point': 0.28; 'correct': 0.29; 'points': 0.29; 'scale': 0.29; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'getting': 0.31; '1.4': 0.31; 'file:': 0.31; 'skip:& 70': 0.31; 'trace': 0.31; 'anyone': 0.31; 'file': 0.32; '(most': 0.33; 'are:': 0.33; 'guess': 0.33; 'skip:_ 10': 0.34; 'could': 0.34; 'skip:s 30': 0.35; 'something': 0.35; 'computing': 0.35; 'point.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'url:org': 0.36; 'should': 0.36; 'unit': 0.37; 'skip:- 20': 0.37; 'minimum': 0.38; 'skip:o 20': 0.38; 'skip:& 10': 0.38; 'thank': 0.38; 'problems': 0.38; 'follows:': 0.38; 'to:addr :python-list': 0.38; 'skip:- 10': 0.38; 'recent': 0.39; 'skip:& 20': 0.39; 'delete': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'skip:p 20': 0.39; 'skip:x 10': 0.40; 'skip:u 10': 0.60; 'read': 0.60; 'flat': 0.60; 'simple,': 0.60; 'skip:n 30': 0.60; 'skip:y 20': 0.60; 'skip:z 20': 0.60; 'skip:\xc2 10': 0.60; 'color': 0.61; 'lower': 0.61; 'full': 0.61; 'new': 0.61; 'first': 0.61; 'maximum': 0.63; 'skip:n 10': 0.64; 'map': 0.64; 'pick': 0.64; 'more': 0.64; 'different': 0.65; 'dear': 0.65; 'bottom': 0.67; 'determine': 0.67; '8bit%:31': 0.68; '8bit%:40': 0.68; 'continuous': 0.68; 'containing': 0.69; 'wish': 0.70; '8bit%:100': 0.72; '8bit%:57': 0.74; '8bit%:46': 0.78; 'hand': 0.80; 'trial': 0.83; '(total': 0.84; '5.7': 0.84; 'contour': 0.84; 'determinant': 0.84; 'dimensional': 0.84; 'distances': 0.84; 'hull': 0.84; 'maximize': 0.84; 'min': 0.84; 'points,': 0.84; 'subject:color': 0.84; '8bit%:70': 0.91; '8bit%:67': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=+6Ocnsvzx6ZoYXw+033l0EgCJZfgbFmHRRsB4sjtRQs=; b=Xv3c/rn2i9BuwMym/z87zKF7e9azRwRyuLEZwiedgPkwyVSfNK0p0AyXI298Gm3aA+ 4HNxRkNjCtaKCnwsgah6s9L64YY4OiNn9QkMKRWdlv+vr9i1q5r2toaL58upYJaG9Fu5 hYeAMGu52BFWx9V7iGAEeGGmfzOwOcJXfhxLuc4XlbsgX804XosPahUUPFXgjhkF/6L5 +SNw35mKM12rV0sPEUp6V85h6Sk04pE04eZ7CkANpDTpQw/fQinSlnW0C0p8hfpPhZak xQkfv51pRvyNfY6x5BA2qeDmj3+8J+o1vJpIMCdh8O9bM+mpK8LT0ap1ZCX10nHV/m+6 GHwA== MIME-Version: 1.0 X-Received: by 10.182.2.43 with SMTP id 11mr463581obr.50.1413527293228; Thu, 16 Oct 2014 23:28:13 -0700 (PDT) Date: Fri, 17 Oct 2014 14:28:13 +0800 Subject: 2d color-bar map plot From: Dhananjay To: python-list@python.org Content-Type: multipart/alternative; boundary=001a1134a592317ea00505987893 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 259 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1413527301 news.xs4all.nl 2917 [2001:888:2000:d::a6]:33635 X-Complaints-To: abuse@xs4all.nl X-Received-Body-CRC: 2707735877 X-Received-Bytes: 17865 Xref: csiph.com comp.lang.python:79235 --001a1134a592317ea00505987893 Content-Type: text/plain; charset=UTF-8 Dear all, I am bit new to the python/pyplot. This might be simple, but I guess I am missing something here. I have data file as follows: 2.1576318858 -1.8651195165 4.2333428278 2.1681875208 -1.9229968780 4.1989176884 2.3387636157 -2.0376253255 2.4460899122 2.1696565965 -2.6186941271 4.4172007912 2.0848862071 -2.1708981985 3.3404520962 2.0824347942 -1.9142798955 3.3629290206 2.0281685821 -1.8103363482 2.5446721669 2.3309993378 -1.8721153619 2.7006893016 2.0957461483 -1.5379071451 4.5228264441 2.2761376261 -2.5935979811 3.9231744717 . . . (total of 200 lines) Columns 1,2,3 corresponds to x,y,z axis data points. 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. As a beginner, I tried to follow tutorial with some modification as follows: http://matplotlib.org/examples/pylab_examples/tricontour_vs_griddata.html # Read data from file: fl1 = open('flooding-psiphi.dat','r').readlines() xs = ys = zs = [] for line in fl1: line = line.split() xs.append(float(line[0])) ys.append(float(line[1])) zs.append(float(line[2])) print xs[0], ys[0], zs[0] xi = np.mgrid[-5.0:5.0:200j] yi = np.mgrid[-5.0:5.0:200j] zi = griddata((x, y), z, (xi, yi), method='cubic') plt.subplot(221) plt.contour(xi, yi, zi, 15, linewidths=0.5, colors='k') plt.contourf(xi, yi, zi, 15, cmap=plt.cm.rainbow, norm=plt.Normalize(vmax=abs(zi).max(), vmin=-abs(zi).max())) plt.colorbar() # draw colorbar plt.plot(x, y, 'ko', ms=3) plt.xlim(-5, 5) plt.ylim(-5, 5) plt.title('griddata and contour (%d points, %d grid points)' % (npts, ngridx*ngridy)) #print ('griddata and contour seconds: %f' % (time.clock() - start)) plt.gcf().set_size_inches(6, 6) plt.show() However, I failed and getting long error as follows: QH6154 qhull precision error: initial facet 1 is coplanar with the interior point ERRONEOUS FACET: - f1 - flags: bottom simplicial upperDelaunay flipped - normal: 0.7071 -0.7071 0 - offset: -0 - vertices: p600(v2) p452(v1) p304(v0) - neighboring facets: f2 f3 f4 While executing: | qhull d Qz Qbb Qt Options selected for Qhull 2010.1 2010/01/14: run-id 1531309415 delaunay Qz-infinity-point Qbbound-last Qtriangulate _pre-merge _zero-centrum Pgood _max-width 8.8 Error-roundoff 1.2e-14 _one-merge 8.6e-14 _near-inside 4.3e-13 Visible-distance 2.5e-14 U-coplanar-distance 2.5e-14 Width-outside 4.9e-14 _wide-facet 1.5e-13 precision problems (corrected unless 'Q0' or an error) 2 flipped facets The input to qhull appears to be less than 3 dimensional, or a computation has overflowed. Qhull could not construct a clearly convex simplex from points: - p228(v3): 2.4 2.4 1.4 - p600(v2): 1.4 1.4 8.8 - p452(v1): 5.7 5.7 8 - p304(v0): -3.1 -3.1 2.4 The center point is coplanar with a facet, or a vertex is coplanar with a neighboring facet. The maximum round off error for computing distances is 1.2e-14. The center point, facets and distances to the center point are as follows: center point 1.595 1.595 5.173 facet p600 p452 p304 distance= 0 facet p228 p452 p304 distance= 0 facet p228 p600 p304 distance= 0 facet p228 p600 p452 distance= 0 These points either have a maximum or minimum x-coordinate, or they maximize the determinant for k coordinates. Trial points are first selected from points that maximize a coordinate. The min and max coordinates for each dimension are: 0: -3.134 5.701 difference= 8.835 1: -3.134 5.701 difference= 8.835 2: -2.118e-22 8.835 difference= 8.835 If the input should be full dimensional, you have several options that may determine an initial simplex: - use 'QJ' to joggle the input and make it full dimensional - use 'QbB' to scale the points to the unit cube - use 'QR0' to randomly rotate the input for different maximum points - use 'Qs' to search all points for the initial simplex - use 'En' to specify a maximum roundoff error less than 1.2e-14. - trace execution with 'T3' to see the determinant for each point. If the input is lower dimensional: - use 'QJ' to joggle the input and make it full dimensional - use 'Qbk:0Bk:0' to delete coordinate k from the input. You should pick the coordinate with the least range. The hull will have the correct topology. - determine the flat containing the points, rotate the points into a coordinate plane, and delete the other coordinates. - add one or more points to make the input full dimensional. Traceback (most recent call last): File "./scatter.py", line 43, in zi = griddata((x, y), z, (xi, yi), method='linear') File "/usr/lib/python2.7/dist-packages/scipy/interpolate/ndgriddata.py", line 183, in griddata ip = LinearNDInterpolator(points, values, fill_value=fill_value) File "interpnd.pyx", line 192, in scipy.interpolate.interpnd.LinearNDInterpolator.__init__ (scipy/interpolate/interpnd.c:2598) File "qhull.pyx", line 948, in scipy.spatial.qhull.Delaunay.__init__ (scipy/spatial/qhull.c:4121) File "qhull.pyx", line 172, in scipy.spatial.qhull._construct_delaunay (scipy/spatial/qhull.c:1314) RuntimeError: Qhull error Could anyone help me to point out what exactly I am missing here. I just wish to plot 2D map with color bar for Z-axis. Thank you in advance. -- DJ --001a1134a592317ea00505987893 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Dear all,
I am bit new to the pyth= on/pyplot.
This might be simple, but I guess I am missing som= ething here.
I have data file as follows:

2.1576318858 -1.8= 651195165 4.2333428278
2.1681875208 -1.9229968780 4.1989176884
2.3387= 636157 -2.0376253255 2.4460899122
2.1696565965 -2.6186941271 4.417200791= 2
2.0848862071 -2.1708981985 3.3404520962
2.0824347942 -1.9142798955 = 3.3629290206
2.0281685821 -1.8103363482 2.5446721669
2.3309993378 -1.= 8721153619 2.7006893016
2.0957461483 -1.5379071451 4.5228264441
2.276= 1376261 -2.5935979811 3.9231744717
.
.
.
(total of 200 li= nes)

Columns 1,2,3 corresponds to x,y,z axis data po= ints.
This is not a continuous data. I wish to make a plot as a 2D with 3rd=20 dimension (i.e z-axis data) as a color map with color bar on right hand=20 side.

As a beginner, I tried to follow tutorial with som= e modification as follows: http://matplotlib.o= rg/examples/pylab_examples/tricontour_vs_griddata.html

# Read data from file:
fl1 =3D open('flooding-psiphi.da= t','r').readlines()
xs =3D ys =3D zs =3D []
for line in f= l1:
=C2=A0=C2=A0=C2=A0 line =3D line.split()
=C2=A0=C2=A0=C2=A0 xs.ap= pend(float(line[0]))
=C2=A0=C2=A0=C2=A0 ys.append(float(line[1]))
=C2= =A0=C2=A0=C2=A0 zs.append(float(line[2]))

print xs[0], ys[0], zs[0]<= br>xi =3D np.mgrid[-5.0:5.0:200j]
yi =3D np.mgrid[-5.0:5.0:200j]
zi = =3D griddata((x, y), z, (xi, yi), method=3D'cubic')
plt.subplot(= 221)

plt.contour(xi, yi, zi, 15, linewidths=3D0.5, colors=3D'k&#= 39;)
plt.contourf(xi, yi, zi, 15, cmap=3Dplt.cm.rainbow, norm=3Dplt.Norm= alize(vmax=3Dabs(zi).max(), vmin=3D-abs(zi).max()))
plt.colorbar()=C2=A0= # draw colorbar
plt.plot(x, y, 'ko', ms=3D3)
plt.xlim(-5, 5)=
plt.ylim(-5, 5)
plt.title('griddata and contour (%d points, %d g= rid points)' %
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 (npts, ngridx*ngridy))
#print ('griddata and contour seconds: %f= ' % (time.clock() - start))
plt.gcf().set_size_inches(6, 6)
plt.s= how()


However, I failed and getting long error as fol= lows:

QH6154 qhull precision error: initial facet 1 is coplanar wit= h the interior point
ERRONEOUS FACET:
- f1
=C2=A0=C2=A0=C2=A0 - fl= ags: bottom simplicial upperDelaunay flipped
=C2=A0=C2=A0=C2=A0 - normal= :=C2=A0=C2=A0=C2=A0 0.7071=C2=A0 -0.7071=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 0
=C2=A0=C2=A0=C2=A0 - offset:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 -0
=C2=A0=C2=A0=C2=A0 - vertices: p600(v2) p452(v1) p= 304(v0)
=C2=A0=C2=A0=C2=A0 - neighboring facets: f2 f3 f4

While e= xecuting:=C2=A0 | qhull d Qz Qbb Qt
Options selected for Qhull 2010.1 20= 10/01/14:
=C2=A0 run-id 1531309415=C2=A0 delaunay=C2=A0 Qz-infinity-poin= t=C2=A0 Qbbound-last=C2=A0 Qtriangulate
=C2=A0 _pre-merge=C2=A0 _zero-ce= ntrum=C2=A0 Pgood=C2=A0 _max-width 8.8=C2=A0 Error-roundoff 1.2e-14
=C2= =A0 _one-merge 8.6e-14=C2=A0 _near-inside 4.3e-13=C2=A0 Visible-distance 2.= 5e-14
=C2=A0 U-coplanar-distance 2.5e-14=C2=A0 Width-outside 4.9e-14=C2= =A0 _wide-facet 1.5e-13

precision problems (corrected unless 'Q0= ' or an error)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 2 flipped facets
The input to qhull appears to be less than 3 dimensional, or a
computa= tion has overflowed.

Qhull could not construct a clearly convex simp= lex from points:
- p228(v3):=C2=A0=C2=A0 2.4=C2=A0=C2=A0 2.4=C2=A0=C2=A0= 1.4
- p600(v2):=C2=A0=C2=A0 1.4=C2=A0=C2=A0 1.4=C2=A0=C2=A0 8.8
- p4= 52(v1):=C2=A0=C2=A0 5.7=C2=A0=C2=A0 5.7=C2=A0=C2=A0=C2=A0=C2=A0 8
- p304= (v0):=C2=A0 -3.1=C2=A0 -3.1=C2=A0=C2=A0 2.4

The center point is copl= anar with a facet, or a vertex is coplanar
with a neighboring facet.=C2= =A0 The maximum round off error for
computing distances is 1.2e-14.=C2= =A0 The center point, facets and distances
to the center point are as fo= llows:

center point=C2=A0=C2=A0=C2=A0 1.595=C2=A0=C2=A0=C2=A0 1.595= =C2=A0=C2=A0=C2=A0 5.173

facet p600 p452 p304 distance=3D=C2=A0=C2= =A0=C2=A0 0
facet p228 p452 p304 distance=3D=C2=A0=C2=A0=C2=A0 0
face= t p228 p600 p304 distance=3D=C2=A0=C2=A0=C2=A0 0
facet p228 p600 p452 di= stance=3D=C2=A0=C2=A0=C2=A0 0

These points either have a maximum or = minimum x-coordinate, or
they maximize the determinant for k coordinates= .=C2=A0 Trial points
are first selected from points that maximize a coor= dinate.

The min and max coordinates for each dimension are:
=C2= =A0 0:=C2=A0=C2=A0=C2=A0 -3.134=C2=A0=C2=A0=C2=A0=C2=A0 5.701=C2=A0 differe= nce=3D 8.835
=C2=A0 1:=C2=A0=C2=A0=C2=A0 -3.134=C2=A0=C2=A0=C2=A0=C2=A0 = 5.701=C2=A0 difference=3D 8.835
=C2=A0 2:=C2=A0 -2.118e-22=C2=A0=C2=A0= =C2=A0=C2=A0 8.835=C2=A0 difference=3D 8.835

If the input should be = full dimensional, you have several options that
may determine an initial= simplex:
=C2=A0 - use 'QJ'=C2=A0 to joggle the input and make i= t full dimensional
=C2=A0 - use 'QbB' to scale the points to the= unit cube
=C2=A0 - use 'QR0' to randomly rotate the input for d= ifferent maximum points
=C2=A0 - use 'Qs'=C2=A0 to search all po= ints for the initial simplex
=C2=A0 - use 'En'=C2=A0 to specify = a maximum roundoff error less than 1.2e-14.
=C2=A0 - trace execution wit= h 'T3' to see the determinant for each point.

If the input i= s lower dimensional:
=C2=A0 - use 'QJ' to joggle the input and m= ake it full dimensional
=C2=A0 - use 'Qbk:0Bk:0' to delete coord= inate k from the input.=C2=A0 You should
=C2=A0=C2=A0=C2=A0 pick the coo= rdinate with the least range.=C2=A0 The hull will have the
=C2=A0=C2=A0= =C2=A0 correct topology.
=C2=A0 - determine the flat containing the poin= ts, rotate the points
=C2=A0=C2=A0=C2=A0 into a coordinate plane, and de= lete the other coordinates.
=C2=A0 - add one or more points to make the = input full dimensional.
Traceback (most recent call last):
=C2=A0 Fil= e "./scatter.py", line 43, in <module>
=C2=A0=C2=A0=C2= =A0 zi =3D griddata((x, y), z, (xi, yi), method=3D'linear')
=C2= =A0 File "/usr/lib/python2.7/dist-packages/scipy/interpolate/ndgriddat= a.py", line 183, in griddata
=C2=A0=C2=A0=C2=A0 ip =3D LinearNDInte= rpolator(points, values, fill_value=3Dfill_value)
=C2=A0 File "inte= rpnd.pyx", line 192, in scipy.interpolate.interpnd.LinearNDInterpolato= r.__init__ (scipy/interpolate/interpnd.c:2598)
=C2=A0 File "qhull.p= yx", line 948, in scipy.spatial.qhull.Delaunay.__init__ (scipy/spatial= /qhull.c:4121)
=C2=A0 File "qhull.pyx", line 172, in scipy.spa= tial.qhull._construct_delaunay (scipy/spatial/qhull.c:1314)
RuntimeError= : Qhull error


Could anyone help me to point out what = exactly I am missing here.
I just wish to plot 2D map with c= olor bar for Z-axis.

Thank you in advance.

=

-- DJ


--001a1134a592317ea00505987893--