Re: [matplotlib-devel] contourf segfaults

2010-02-24 Thread Ian Thomas
Eric,

> I hit a bug (segfault) in cntr.c that is likely related to your changes. It
> is ID 2956378 in the tracker.

Attached is a patch file with a fix for this bug.  I've also included
a minimal test file to demonstrate the behaviour before and after the
fix, along with a brief explanation which I can expand upon if you
wish.

Ian
Index: src/cntr.c
===
--- src/cntr.c	(revision 8150)
+++ src/cntr.c	(working copy)
@@ -605,6 +605,9 @@
 }
 if (fwd < 0 && level0 && left < 0)
 {
+		/* remove J0_START from this boundary edge as boundary is
+		 * included by the upwards slit from contour line below. */
+data[edge] &= ~J0_START;
 if (n_kind) kcp[n_kind] += kind_start_slit;
 return slit_cutter (site, 0, pass2);
 }
#!/usr/bin/env python
#
# Minimal example to demonstrate bug ID 2956378 and its fix.
#
# Bug causes infinite loop leading to segmentation fault.  Infinite loop occurs
# as contouring code repeated restarts walking around the edge of a masked
# hole that is linked, via a vertical slit, to the contour line below (with a
# lower j-index).  Such a hole should not be a contour starting edge as it is
# included in the contour line that it is slit up from.  The solution is to
# prevent such a hole from being a possible contour starting edge by removing
# its J0_START flag.
#
# Bug is only visible if there is at least one other starting edge in the same
# row of the grid, otherwise the erroneous starting edge is ignored.

from pylab import *

z = ones((5,6))
z[2,2] = ma.masked
z[:,-2:] = 0
z[1,-1] = 1# Force another contour starting edge in the same row.

levels = [0.5, 2]
contourf(z, levels, alpha=0.5)
colorbar()
contour(z, levels)
axis([-0.2, 5.2, -0.2, 4.2])
show()
--
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] An easier way to create figure and group of axes; useful?

2010-02-24 Thread Fernando Perez
On Tue, Feb 23, 2010 at 10:14 PM, Fernando Perez  wrote:

> Final question: should I put the little demo code at the bottom that I
> used for testing this up in an example file?  I put some of that in
> the docstring as an example, but not all to avoid clutter.

OK, since I know people are busy, I took silence as acquiescence.
Committed in r8151, please let me know if I messed anything up and
I'll try to fix it.  I'm used to the numpy docstring standard, but I
tried to adapt it to the mpl  one by looking at the rest of pyplot,
let me know if  it needs fine-tuning.

Cheers,

f

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


[matplotlib-devel] many mplot3d fixes

2010-02-24 Thread Ben Axelrod
Here is a major patch for mplot3d.  Here is a summary of the changes:

 * bug fix: placement of title in 3D plots to match 2D plot behavior (see 
nonecolortester.py to demonstrate)
 * bug fix: allow facecolors and edgecolors to be specified as 'none' in 3D 
scatter plots to match the 2D scatter plot behavior (see nonecolortester.py to 
demonstrate)
 * bug fix: allow all keyword arguments to be used in text3D (see modified 
example code text3d_demo.py)
 * bug fix: allow an array of colors to be passed into bar3d to specify the 
colors on a per-bar or per-face basis (see new example code hist3d_demo2.py)
 * bug fix: allow all keyword arguments to be used in bar3d (see new example 
code hist3d_demo2.py)
 * bug fix: allow 3d scatter plots with 3 or 4 points with colors specified 
(see colortester2.py to demonstrate)
 * new feature: new method to disable mouse rotation in 3D plots
 * new feature: allow mouse rotation and zoom buttons to be specified by user
 * new feature: new Z-order sorting heuristic to eliminate rendering issues for 
the common case of using bar3d to visualize a 2D histogram (see modified 
example code hist3d_demo.py)
 * new feature: new method text2D (see modified example code text3d_demo.py)
 * code cleanup: warn when canvas is None which disables mouse callbacks
 * code cleanup: document more methods in mplot3d

Thanks,
-Ben#!/usr/bin/env python
#
# Test script to test:
# * facecolor and edgecolor = 'none' in Axes3D
# * tile placement on Axes3D
#
# Compare 2D and 3D axes with the same titles to match functionality.
#
# Note that before patch:
# * Title in figure 2 is missing
# * Figures 4 and 6 are blank with exceptions on the console
#
# After patch, everything works fine.
#
# Ben Axelrod
# Feb. 24, 2010


import numpy as np
import matplotlib.pyplot as plt

from mpl_toolkits.mplot3d import Axes3D

xs = [1,2,3,4,5,6]
ys = [1,2,3,4,5,6]
zs = [1,2,3,4,5,6]
cs = [1,2,3,4,5,6]




fig1 = plt.figure()
ax1 = fig1.add_subplot(111)

ax1.scatter(xs, ys,
facecolor='y',
edgecolor='r')
ax1.set_title("2D   facecolor='y'   edgecolor='r'")

##

fig2 = plt.figure()
ax2 = Axes3D(fig2)

ax2.scatter(xs, ys, zs,
facecolor='y',
edgecolor='r')
ax2.set_title("3D   facecolor='y'   edgecolor='r'")



fig3 = plt.figure()
ax3 = fig3.add_subplot(111)

ax3.scatter(xs, ys,
facecolor='none',
edgecolor=(1,0,0))
ax3.set_title("2D   facecolor='none'   edgecolor=(1,0,0)", ha='left', y=1, x=0.1)

##

fig4 = plt.figure()
ax4 = Axes3D(fig4)

ax4.scatter(xs, ys, zs,
facecolor='none',
edgecolor=(1,0,0))
ax4.set_title("3D   facecolor='none'   edgecolor=(1,0,0)", ha='left', y=1, x=0.1)



fig5 = plt.figure()
ax5 = fig5.add_subplot(111)

ax5.scatter(xs, ys,
edgecolor='none')
ax5.set_title("2D   edgecolor=(1,0,0)",color='g', y=0)

##

fig6 = plt.figure()
ax6 = Axes3D(fig6)

ax6.scatter(xs, ys, zs,
edgecolor='none')
ax6.set_title("3D   edgecolor=(1,0,0)", color='g', y=0)



plt.show()

#!/usr/bin/env python
#
# Test script to test color bug in Axes3d scatter plot when number of points
# is 3 or 4 and colors are specified.
#
# Note that before patch, figures 10, 11, 13, 14 are blank due to exceptions.
# After patch, these plots display like they should.
#
# Note that color map doesn't work yet for the 3d scatter plot
#
# Ben Axelrod
# Feb. 24, 2010


import numpy as np
import matplotlib.pyplot as plt

from mpl_toolkits.mplot3d import Axes3D

xs = [1,2,3,4,5]
ys = [1,2,3,4,5]
zs = [1,2,3,4,5]
cs = [1,2,3,4,5]

cstrings = ['r', 'g', 'b', 'c', 'm']
carrays = [(1,0,0,1), (0,1,0,1), (0,0,1,1), (0,1,1,1), (1,0,1,1)]




for n in [3, 4, 5]:
fig = plt.figure()
ax = fig.add_subplot(111)
ax.scatter(xs[:n], ys[:n], c=cstrings[:n])
ax.set_title("2D  using cstrings")

for n in [3, 4, 5]:
fig = plt.figure()
ax = fig.add_subplot(111)
ax.scatter(xs[:n], ys[:n], c=carrays[:n])
ax.set_title("2D  using carrays")

for n in [3, 4, 5]:
fig = plt.figure()
ax = fig.add_subplot(111)
ax.scatter(xs[:n], ys[:n], c=cs[:n], cmap='jet')
ax.set_title("2D  using cmap")




for n in [3, 4, 5]:
fig = plt.figure()
ax = Axes3D(fig)
ax.scatter(xs[:n], ys[:n], zs[:n], c=cstrings[:n])
ax.set_title("3D  using cstrings")

for n in [3, 4, 5]:
fig = plt.figure()
ax = Axes3D(fig)
ax.scatter(xs[:n], ys[:n], zs[:n], c=carrays[:n])
ax.set_title("3D  using carrays")

for n in [3, 4, 5]:
fig = plt.figure()
ax = Axes3D(fig)
ax.scatter(xs[:n], ys[:n], zs[:n], c=cs[:n], cmap='jet')
ax.set_title("3D  using cmap")

##

plt.show()

Index: lib/mpl_toolkits/mplot3d/art3d.py
==

Re: [matplotlib-devel] contourf segfaults

2010-02-24 Thread Eric Firing
Ian Thomas wrote:
> Eric,
> 
>> I hit a bug (segfault) in cntr.c that is likely related to your changes. It
>> is ID 2956378 in the tracker.
> 
> Attached is a patch file with a fix for this bug.  I've also included
> a minimal test file to demonstrate the behaviour before and after the
> fix, along with a brief explanation which I can expand upon if you
> wish.
> 
> Ian

Ian,

Excellent!  Applied in svn 8152.  I also added your test case to the 
tracker and closed the bug. Thanks for the great work!

Eric

--
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] many mplot3d fixes

2010-02-24 Thread Reinier Heeres
Hi Ben, all,

First of all: thanks for your patch. With a few minor modifications I
think we should apply most of it. I had a quick look now, but let's
aim to get it in over the weekend.

Let me also say that as far as I'm concerned, mplot3d is here to stay
and I will try to continue to support it. However, some help for this
would be greatly appreciated, and it seems you can find your way
around the code just fine!

- I'm not entirely sure whether the CuboidCollection class you wrote
is completely necessary, wouldn't it also be possible to use
Poly3DCollection instances? (which should be correctly sorted). Then
the only thing that would have to be added to Poly3DCollection is the
histogram heuristic.

- For the text() function, I think we should probably pass all kwargs
to Axes.text() instead of the explicit version you used.

- If you don't mind I'll remove the #endif etc comments, they appear
nowhere in the codebase as far as I know.

Pleas let me know what you think!

Cheers,
Reinier

On Wed, Feb 24, 2010 at 7:39 PM, Ben Axelrod  wrote:
> Here is a major patch for mplot3d.  Here is a summary of the changes:
>
>  * bug fix: placement of title in 3D plots to match 2D plot behavior (see 
> nonecolortester.py to demonstrate)
>  * bug fix: allow facecolors and edgecolors to be specified as 'none' in 3D 
> scatter plots to match the 2D scatter plot behavior (see nonecolortester.py 
> to demonstrate)
>  * bug fix: allow all keyword arguments to be used in text3D (see modified 
> example code text3d_demo.py)
>  * bug fix: allow an array of colors to be passed into bar3d to specify the 
> colors on a per-bar or per-face basis (see new example code hist3d_demo2.py)
>  * bug fix: allow all keyword arguments to be used in bar3d (see new example 
> code hist3d_demo2.py)
>  * bug fix: allow 3d scatter plots with 3 or 4 points with colors specified 
> (see colortester2.py to demonstrate)
>  * new feature: new method to disable mouse rotation in 3D plots
>  * new feature: allow mouse rotation and zoom buttons to be specified by user
>  * new feature: new Z-order sorting heuristic to eliminate rendering issues 
> for the common case of using bar3d to visualize a 2D histogram (see modified 
> example code hist3d_demo.py)
>  * new feature: new method text2D (see modified example code text3d_demo.py)
>  * code cleanup: warn when canvas is None which disables mouse callbacks
>  * code cleanup: document more methods in mplot3d
>
> Thanks,
> -Ben
> --
> 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
>
>



-- 
Reinier Heeres
Tel: +31 6 10852639

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