Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79235

2d color-bar map plot

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 <dhananjay.c.joshi@gmail.com>
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 <dhananjay.c.joshi@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.14939.1413527301.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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 <module>
    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

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

2d color-bar map plot Dhananjay <dhananjay.c.joshi@gmail.com> - 2014-10-17 14:28 +0800
  Re: 2d color-bar map plot Peter Pearson <pkpearson@nowhere.invalid> - 2014-10-17 15:51 +0000

csiph-web