Re: [matplotlib-devel] Contouring unstructured triangular grids

2010-04-12 Thread Ian Thomas
Eric Firing wrote:
> I've only glanced so far, but one thing that caught my eye is your
> documentation changes and code regarding the need for simply-connected
> paths.  This is obsolete--mpl now handles multiply-connected paths.

Thanks for clarifying this, I now understand the 'point kinds' in
cntr.c which I originally thought were for debug purposes.  It will
make my code simpler in the end.

> A second initial suggestion is that you divide the work into two patches,
> one of which provides the refactoring of existing code (presumably only in
> contour.py), and a second which adds the new functionality.

Good idea.  I've attached the first patch which changes axes.py and
contour.py, plus adds the new example contour_manual.py.  My approach
to the refactoring is probably more of a C++ than pythonic way of
thinking with derived classes that override base class methods, but it
avoids changing much of the low level code and avoids code duplication
when tricontour is added in.

Ian
Index: lib/matplotlib/contour.py
===
--- lib/matplotlib/contour.py	(revision 8226)
+++ lib/matplotlib/contour.py	(working copy)
@@ -577,7 +577,7 @@
 
 class ContourSet(cm.ScalarMappable, ContourLabeler):
 """
-Create and store a set of contour lines or filled regions.
+Store a set of contour lines or filled regions.
 
 User-callable method: clabel
 
@@ -592,17 +592,49 @@
 same as levels for line contours; half-way between
 levels for filled contours.  See _process_colors method.
 """
-
-
 def __init__(self, ax, *args, **kwargs):
 """
 Draw contour lines or filled regions, depending on
 whether keyword arg 'filled' is False (default) or True.
 
-The first argument of the initializer must be an axes
-object.  The remaining arguments and keyword arguments
-are described in ContourSet.contour_doc.
+The first three arguments must be:
 
+  *ax*: axes object.
+
+  *levels*: [level0, level1, ..., leveln]
+A list of floating point numbers indicating the contour
+levels.
+
+  *allsegs*: [level0segs, level1segs, ...]
+List of all the polygon segments for all the *levels*.
+For contour lines len(allsegs) == len(levels), and for
+filled contour regions len(allsegs) = len(levels)-1.
+
+level0segs = [polygon0, polygon1, ...]
+
+polygon0 = array_like [[x0,y0], [x1,y1], ...]
+
+  *allkinds*: None or [level0kinds, level1kinds, ...]
+Optional list of all the polygon vertex kinds (code types), as
+described and used in Path.   This is used to allow multiply-
+connected paths such as holes within filled polygons.
+If not None, len(allkinds) == len(allsegs).
+
+level0kinds = [polygon0kinds, ...]
+
+polygon0kinds = [vertexcode0, vertexcode1, ...]
+
+If allkinds is not None, usually all polygons for a particular
+contour level are grouped together so that
+
+level0segs = [polygon0] and level0kinds = [polygon0kinds].
+
+Keyword arguments are as described in
+:class:`~matplotlib.contour.QuadContourSet` object.
+
+**Examples:**
+
+.. plot:: mpl_examples/misc/contour_manual.py
 """
 self.ax = ax
 self.levels = kwargs.get('levels', None)
@@ -638,24 +670,7 @@
 raise ValueError('Either colors or cmap must be None')
 if self.origin == 'image': self.origin = mpl.rcParams['image.origin']
 
-if isinstance(args[0], ContourSet):
-C = args[0].Cntr
-if self.levels is None:
-self.levels = args[0].levels
-else:
-x, y, z = self._contour_args(args, kwargs)
-
-x0 = ma.minimum(x)
-x1 = ma.maximum(x)
-y0 = ma.minimum(y)
-y1 = ma.maximum(y)
-self.ax.update_datalim([(x0,y0), (x1,y1)])
-self.ax.autoscale_view()
-_mask = ma.getmask(z)
-if _mask is ma.nomask:
-_mask = None
-C = _cntr.Cntr(x, y, z.filled(), _mask)
-self.Cntr = C
+self._process_args(*args, **kwargs)
 self._process_levels()
 
 if self.colors is not None:
@@ -673,28 +688,23 @@
 kw['norm'] = norm
 cm.ScalarMappable.__init__(self, **kw) # sets self.cmap;
 self._process_colors()
+
+self.allsegs, self.allkinds = self._get_allsegs_and_allkinds()
+
 if self.filled:
 if self.linewidths is not None:
 warnings.warn('linewidths is ignored by contourf')
 
-lowers = self._levels[:-1]
-if self.zmin == lowers[0]:
-# Include minimum values in lowest interval
-lowers = lowers.copy() # so we don't change self._levels
-if 

Re: [matplotlib-devel] [sage-devel] Re: OS X 10.6 port

2010-04-12 Thread Ondrej Certik
On Mon, Sep 28, 2009 at 9:37 AM, William Stein  wrote:
>
> On Mon, Sep 28, 2009 at 9:35 AM, John Hunter  wrote:
>> On Mon, Sep 28, 2009 at 11:14 AM, John Hunter  wrote:
>>
>>> But even simple tests are failing with::
>>>
>>> jdh2...@bsd:~> LD_LIBRARY_PATH=~/devtest/lib/
>>> PYTHONPATH=~/devtest/lib/python2.6/site-packages/ /usr/bin/python -c
>>> 'import matplotlib; matplotlib.use("Agg"); from matplotlib.pyplot
>>> import *; plot([1,2,3]); savefig("test")'
>>> Traceback (most recent call last):
>>>  File "", line 1, in 
>>>  File 
>>> "/Users/jdh2358/devtest//lib/python2.6/site-packages/matplotlib/pyplot.py",
>>> line 7, in 
>>>    from matplotlib.figure import Figure, figaspect
>>>  File 
>>> "/Users/jdh2358/devtest//lib/python2.6/site-packages/matplotlib/figure.py",
>>> line 16, in 
>>>    import artist
>>>  File 
>>> "/Users/jdh2358/devtest//lib/python2.6/site-packages/matplotlib/artist.py",
>>> line 6, in 
>>>    from transforms import Bbox, IdentityTransform, TransformedBbox,
>>> TransformedPath
>>>  File 
>>> "/Users/jdh2358/devtest//lib/python2.6/site-packages/matplotlib/transforms.py",
>>> line 34, in 
>>>    from matplotlib._path import affine_transform
>>> ImportError: 
>>> /Users/jdh2358/devtest/lib/python2.6/site-packages/matplotlib/_path.so:
>>> no appropriate 64-bit architecture (see "man python" for running in
>>> 32-bit mode)
>>>
>>> I'm attaching my build output in case anyone sees anything that might
>>> be triggering this 32bit/64bit problem (see attached for full output).
>>>  I did not rebuild numpy and this may be the problem since the failure
>>> is in the _path module.  I'll give that a try next
>>
>>
>> Same issue with numpy HEAD
>
> One thing to keep in mind is that the default for GCC on OS X 10.6 is
> to build 64-bit binaries.   With OS X 10.5 the default for GCC was to
> make 32-bit binaries.  (To get 64-bit you used to have to do "-m64",
> but that is now the default.)   So you really have to start from
> scratch.

I am now getting the exact same problem with pylab and FEMhub and Mac.
I used http://sagemath.org/packages/standard/matplotlib-0.99.1.p4.spkg:

ond...@bsd:~/repos/femhub-0.9.9.beta3-mac(master)$ ./femhub
--
| FEMhub Version 0.9.9.beta2, Release Date: 2010-04-02   |
| Type lab() for the GUI.|
--
In [1]: import pylab
/Users/ondrej/repos/femhub-0.9.9.beta3-mac/local/lib/python2.6/site-packages/matplotlib/rcsetup.py:117:
UserWarning: rcParams key "numerix" is obsolete and has no effect;
 please delete it from your matplotlibrc file
  warnings.warn('rcParams key "numerix" is obsolete and has no effect;\n'
/Users/ondrej/repos/femhub-0.9.9.beta3-mac/local/bin/sage-sage: line
203: 28516 Abort trap  sage-ipython "$@" -i



It's using the "bsd" Mac machine from William, I guess the same as
John was using above.


Has anybody figured out a solution? Apparently Sage must work on the
Mac, so it must be something different than just matplotlib? Some
other package, that we have in femhub, but not in Sage, or some
different version of something. Here is a list of packages that I have
installed:

ond...@bsd:~/repos/femhub-0.9.9.beta3-mac(master)$ ./femhub -i
Currently installed packages:
blas-20070724
bzip2-1.0.5
cmake-2.6.2.p1
configobj-4.5.3
cython-0.12.1
dir-0.1
docutils-0.5.p0
femhub-lab-97141eb
fipy-2.1-eb4aacf
fortran-20071120.p8
freetype-2.3.5.p2
gnutls-2.2.1.p3
hermes2d-9bbfd39
ipython-bzr1174
jinja-1.2.p0
judy-1.0.5.p1
lapack-20071123.p1
libfemhub-78c07cb
libgcrypt-1.4.3.p2
libgpg_error-1.6.p2
libpng-1.2.35.p0
matplotlib-0.99.1.p4
mayavi-3.3.1.p2
mesa-7.4.4.p3
numpy-1.3.0.p2
pexpect-2.0.p3
prereq-0.3
pygments-0.11.1.p0
pyparsing-1.5.2
pysparse-1.1-6301cea
python-2.6.4.p7
python_gnutls-1.1.4.p7
readline-6.0
sage_scripts-3.4.2
scipy-0.7.p4
setuptools-0.6c9.p0
sfepy-2009.3
sphinx-0.6.3.p4
swig-1.3.36
sympy-5d78c29
termcap-1.3.1.p1
twisted-9.0.p2
vtk-cvs-20090316-minimal.p6
zlib-1.2.3.p5


Let me know if you have any hints what to try.

Ondrej

--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] qt4_editor

2010-04-12 Thread Gökhan Sever
On Sun, Apr 11, 2010 at 1:53 PM, Peter Butterworth wrote:

> I've now uploaded the final version for review at the sourceforge tracker :
>
> https://sourceforge.net/tracker/?func=detail&aid=2981606&group_id=80706&atid=560722
>
> figureoptions.py: modify plot options interactively (see attached
> screenshot)
> Requires PyQt4 installed
>
> Support of :
> - Axes (xy scale)
> - Legend
> - Lines
> - Patches (Rectangle, Ellipse, Polygon, dolphins...)
> - Texts
>
> Ignores :
> - Collections
>
> Limitations:
> - not available for multiple axes in the same subplot
>

Hello,

I couldn't make options in Texts tab working. I simply add a text by:

plt.text(0,1, "test")

Texts tab appears however nothing functions. I get errors ending with
"TypeError: 'str' object is not callable" in my each try.

Could the similar text-editing functionality be added for label and title
text? It would be nice to update them via these menus.

-- 
Gökhan
--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel