John Hunter | 1 Jul 15:39

scipy conference

After a two year hiatus where I inadvertently scheduled my travel
plans to overlap scipy, I will finally be able to make it to the scipy
conference this year, and plan to make up for lost time by coming
early to lead a tutorial on advanced mpl usage, stay through the
conference, and if any of you are interested, do a sprint.  There are
lots of interesting things we can work on: refactoring the ticks to
work nicely with the new spines, pushing forward on the documentation,
optimizing stuff that is too slow or memory intensive, improving the
animation API and backend support, gradients, ....

Anyone interested?  And if so, feel free to suggest topics or weigh in
on some I listed.

Also, if any of you will be there early for the tutorials, it would be
great to have some help  from floaters, people who walk around the
room and help people who get stuck during the hands-on examples or
teachers, people who lead part of the tutorial.  In particular,
Michael could do a segment on transforms and paths, JJ could do a
segment on all his fancy arrows, boxes, annotations, etc, Andrew on
his spines, Reinier on mplot3d, etc...  I will probably cover all of
these even if you can't attend or don't want to teach, but it is best
ot hear from the experts.  And if anyone not mentioned wants to
contribute a segment, that would be great -- just let me know what it
is.  The tutorial is 2 hours and focuses on advanced mpl usage so I
want to avoid the everyday stuff and focus on transforms, paths, event
handling, animation, the newer features (spines, fancy*, mplot3d) and
everything else I am currently forgetting.

Also, we have raised a few hundred dollars in donations, so we could
either fly a worthy person out who might not otherwise be able to
(Continue reading)

Jörgen Stenarson | 30 Jun 20:44

Fatal python error on ipython exit

Hi,

I have a crash using current matplotlib binary build for windows on 
python2.6

If I have active figures open when exiting ipython -pylab using ctrl-d I 
get a:

Fatal Python error: PyEval_RestoreThread: NULL tstate

and a crashdialog, see attached bmp

This does not happen if I close the windows before exiting

Using:
windows XP
python2.6
matplotlib-0.98.5.3 binary installer
numpy-1.3.0
scipy-0.7.1rc3

/Jörgen

------------------------------------------------------------------------------
_______________________________________________
(Continue reading)

Ray Speth | 30 Jun 18:49
Favicon

improved performance for quiver

I believe I have found a simple change that improves the rendering speed 
of quiver plots, which can be quite slow for large vector fields. Based 
on some profiling, the problem appears to stem from the use of numpy's 
MaskedArrays in PolyCollection.set_verts. If I add the following line to 
the top of the PolyCollection.set_verts function in collections.py:

	verts = np.asarray(verts)

I find that quiver plots are drawn about 3 times as quickly, going from 
2.6 seconds for a 125x125 field to 0.65 seconds. This does not seem to 
break the use of MaskedArrays as inputs, and masked regions are still 
hidden in the final plot. I do not know if this has any adverse effects 
in other classes that inherit from PolyCollection.

Using:
python 2.6.2 on Windows XP
numpy 1.3.0
matplotlib 0.98.5.3, Qt4Agg backend

I do not know why iterating over MaskedArrays is so slow, but perhaps 
this information can be used to speed up some other functions as well.

Ray Speth

------------------------------------------------------------------------------
Ch B Komaki | 30 Jun 10:08
Favicon

TypeError: 'Bbox' object is not iterable

Dear sirs/madams,
There is bug on  

>>> from pylab import *
>>> from pylab import *
>>> fig=figure(figsize=(8,8))
>>> ax = fig.add_axes([0.1,0.1,0.7,0.7])
>>> l,b,w,h = ax.get_position()
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
TypeError: 'Bbox' object is not iterable
>>> ax.get_position()
Bbox(array([[ 0.1,  0.1],
       [ 0.8,  0.8]]))
I suggest this;
[l,b],[w,h]=ax.get_position().get_points()

As its is a bug on
basemap-0.9.5\examples\plotmap.py", line 34, in <module>
    l,b,w,h = ax.get_position()
TypeError: 'Bbox' object is not iterable
 best regards 


------------------------------------------------------------------------------
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Ch B Komaki | 30 Jun 10:08
Favicon

'Polygon' object has no attribute '_paths'

There is a problem on pylab ,Windows
Traceback (most recent call last):
  File "....\basemap-0.9.5\examples\plot_tissot.py", line 59, in <module>
    m.drawmapboundary()
  File "C:\Python25\Lib\site-packages\matplotlib\toolkits\basemap\basemap.py", line 1227, in drawmapboundary
    ax.add_collection(bound)
  File "C:\Python25\Lib\site-packages\matplotlib\axes.py", line 1320, in add_collection
    if collection._paths and len(collection._paths):
AttributeError: 'Polygon' object has no attribute '_paths'

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Ryan Wagner | 29 Jun 18:00
Favicon

mplot3d contour patch on tracker

Hi, I submitted a new patch on the tracker. When I was playing with the contour routine in mplot3d and using the extend3d keyword it would error out. I’ve attached a sample program to display the error as well as the dataset I was using. Please feel free to contact me if there are any questions regarding this.

 

Ryan Wagner

Support/Consulting Engineer

Visual Numerics Inc.

rwagner-ioOG6gXtPvA@public.gmane.org

 

 

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Tobias Wood | 22 Jun 15:11
Favicon

Strange bit-depth PNGs

Dear list,
Back in April I submitted a patch that allowed imread() to correctly read  
PNGs that have odd bit-depths, ie not 8 or 16 (I actually submitted that  
to the Users list as I was unsure of protocol). There were a couple of  
things I left unfinished that I've finally got round to looking at again.

The main remaining issue for me is that PNG specifies that all bit depths  
should be scaled to have the same maximum brightness, so that a value of  
8191 in an 13-bit image is displayed the same as 65535 in a 16-bit image.  
Unfortunately, the LabView drivers for the 12-bit CCD in our lab do not  
follow this convention. A higher bit-depth from this setup means the image  
was brighter in an absolute sense and no scaling takes place. So this is  
not an error with Matplotlib as such, but more about having a decent way  
to handle iffy PNGs. It is worth noting that Matlab does not handle these  
PNGs well either (We have to query the image file using iminfo and then  
correct it) and PIL ignores anything above 8-bits as far as I can tell.

A simple method, in my mind, and originally suggested by Andrew Straw is  
to add a keyword argument to imread() that indicates whether a user wants  
floats scaled between 0 and 1, or the raw byte values which they can then  
scale as required. This then gets passed to read_png(), which does the  
scaling if necessary and if not returns an array of UINT16s. I wrote a  
patch that does this, changing both image.py and _png.cpp. I'm very much  
open to other suggestions, as I didn't particularly want to fiddle with a  
core function like imread() and I'm fairly new to Python. In particular I  
have not changed anything to do with PIL - although it would not be much  
work to update pil_to_array() to follow the same behaviour as read_png().  
I have tested this with the pngsuite.py*, and if desired I can submit an  
extended version of this that tests the extended bit-depth images from the  
PNG suite.

Thanks in advance,
Toby Wood

* My patch also includes a minor change to pngsuite.py which was throwing  
a deprecation warning about using get_frame() istead of patch
Index: src/_png.cpp
===================================================================
--- src/_png.cpp	(revision 7230)
+++ src/_png.cpp	(working copy)
@@ -178,8 +178,11 @@
 Py::Object
 _png_module::read_png(const Py::Tuple& args) {

-  args.verify_length(1);
+  args.verify_length(1,2);
   std::string fname = Py::String(args[0]);
+  bool raw = false;
+  if (args.length() == 2)
+    raw = Py::Boolean(args[1]);

   png_byte header[8];	// 8 is the maximum size that can be checked

@@ -213,16 +216,21 @@
   png_uint_32 width = info_ptr->width;
   png_uint_32 height = info_ptr->height;

+  // Bit depth can be 1, 2, 4, 8, or 16
   int bit_depth = info_ptr->bit_depth;
-
+  double max_value = (1 << bit_depth) - 1; // For scaling later
   // Unpack 1, 2, and 4-bit images
   if (bit_depth < 8)
     png_set_packing(png_ptr);

-  // If sig bits are set, shift data
+  // If a pngs max value does not use the full bit depth, then values are shifted up during writing.
+  // This shifts them back and then recalculates max_value
   png_color_8p sig_bit;
   if ((info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) && png_get_sBIT(png_ptr, info_ptr, &sig_bit))
+  {
     png_set_shift(png_ptr, sig_bit);
+	max_value = (1 << sig_bit->red) - 1; // RGB values appear to always be equal
+  }

   // Convert big endian to little
   if (bit_depth == 16)
@@ -260,12 +268,13 @@
     dimensions[2] = 3;     //RGB images
   else
     dimensions[2] = 1;     //Greyscale images
+
   //For gray, return an x by y array, not an x by y by 1
   int num_dims  = (info_ptr->color_type & PNG_COLOR_MASK_COLOR) ? 3 : 2;
+  
+  // If read mode is raw give back ints, otherwise float between 0 and 1
+  PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew(num_dims, dimensions, (raw) ?
PyArray_UINT16 : PyArray_FLOAT);

-  double max_value = (1 << ((bit_depth < 8) ? 8 : bit_depth)) - 1;
-  PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew(num_dims, dimensions, PyArray_FLOAT);
-
   for (png_uint_32 y = 0; y < height; y++) {
     png_byte* row = row_pointers[y];
 	for (png_uint_32 x = 0; x < width; x++) {
@@ -273,13 +282,13 @@
 	  if (bit_depth == 16) {
 	    png_uint_16* ptr = &reinterpret_cast<png_uint_16*> (row)[x * dimensions[2]];
             for (png_uint_32 p = 0; p < (png_uint_32)dimensions[2]; p++)
-	      *(float*)(A->data + offset + p*A->strides[2]) = (float)(ptr[p]) / max_value;
+			  raw ? *reinterpret_cast<unsigned short*>(A->data + offset + p*A->strides[2]) = ptr[p] :
+	                *reinterpret_cast<float*>(A->data + offset + p*A->strides[2]) = static_cast<float>(ptr[p]) / max_value;
 	  } else {
 	    png_byte* ptr = &(row[x * dimensions[2]]);
 	    for (png_uint_32 p = 0; p < (png_uint_32)dimensions[2]; p++)
-		{
-	      *(float*)(A->data + offset + p*A->strides[2]) = (float)(ptr[p]) / max_value;
-	    }
+		  raw ? *reinterpret_cast<unsigned short*>(A->data + offset + p*A->strides[2]) = ptr[p] :
+	            *reinterpret_cast<float*>(A->data + offset + p*A->strides[2]) = static_cast<float>(ptr[p]) / max_value;
 	  }
     }
   }
Index: lib/matplotlib/image.py
===================================================================
--- lib/matplotlib/image.py	(revision 7230)
+++ lib/matplotlib/image.py	(working copy)
@@ -739,7 +739,7 @@
         rows, cols, buffer = im.as_rgba_str()
         _png.write_png(buffer, cols, rows, fname)

-def imread(fname):
+def imread(fname, raw=False):
     """
     Return image file in *fname* as :class:`numpy.array`.

@@ -773,7 +773,7 @@
         return im

     handler = handlers[ext]
-    return handler(fname)
+    return handler(fname, raw)

 
 def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None, origin=None):
Index: examples/tests/pngsuite/pngsuite.py
===================================================================
--- examples/tests/pngsuite/pngsuite.py	(revision 7230)
+++ examples/tests/pngsuite/pngsuite.py	(working copy)
@@ -24,6 +24,6 @@
         cmap = cm.gray
     plt.imshow(data, extent=[i,i+1,0,1], cmap=cmap)

-plt.gca().get_frame().set_facecolor("#ddffff")
+plt.gca().patch.set_facecolor("#ddffff")
 plt.gca().set_xlim(0, len(files))
 plt.show()
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Brad Chivari | 18 Jun 19:40

Potential Bug in axes.py

SUBJECT:
Filtering out 0 bar height/width not working

FILE:
matplotlib/ trunk/ matplotlib/ lib/ matplotlib/ axes.py

PROBLEM:
xmin = np.amin(width[width!=0]) # filter out the 0 width rects
ymin = np.amin(height[height!=0]) # filter out the 0 height rects

These aren't using proper python list comprehension and don't work as expected (for me anyway).

SOLUTION:
Shouldn't they be something like:
xmin = np.amin([w for w in width if w != 0])
ymin = np.amin([h for h in height if h != 0])

Once I changed them they seem to work properly.

Thanks,
Brad

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
vehemental | 17 Jun 16:00

Large datasets performance....


Hello,

I'm using matplotlib for various tasks beautifully...but on some occasions,
I have to visualize large datasets (in the range of 10M data points) (using
imshow or regular plots)...system start to choke a bit at that point...

I would like to be consistent somehow and not use different tools for
basically similar tasks...
so I'd like some pointers regarding rendering performance...as I would be
interested to be involved in dev is there is something to be done....

To active developers, what's the general feel does matplotlib have room to
spare in its rendering performance?...
or is it pretty tied down to the speed of Agg right now?
Is there something to gain from using the multiprocessing module now
included by default in 2.6?
or even go as far as using something like pyGPU for fast vectorized
computations...?

I've seen around previous discussions about OpenGL being a backend in some
future...
would it really stand up compared to the current backends? is there clues
about that right now?

thanks for any inputs! :D
bye
--

-- 
View this message in context: http://www.nabble.com/Large-datasets-performance....-tp24074329p24074329.html
Sent from the matplotlib - devel mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
Jae-Joon Lee | 17 Jun 02:34

image filtering (e.g. dropshadow) for agg backend

Hi,

Attached is a patch to support some primitive image filtering (e.g.,
gaussian blur) for agg backend.
The idea is similar to how rasterization is done.
Instead of plotting the rasterized image on the vector backend, it
plots the image (after filtering) on the same agg backend.

The demo image is attached.
It is simple image processing filter and only available for agg
backend. However, you can use this by rasterization (pdf, svg, ps).
For example, saving the demo as pdf works, except the misaligned texts.

Although this is only for the agg backend, I guess this is rather
useful and want to push into the trunk.
The big question is its api. Right now, its api is mostly similar to
rasterization api and it utilizes the "allow_rasterization" decorator.
I think one of the key thing to be considered is how filtering in
other back ends will be implemented (if they are going to).
Right now, the filtering is done by simple function that does some
array arithmetic, but different back end will require different
functions.
Maybe, we need some filter classes which implements filtering function
for each backends.

So, it would be great if others test the patch and give some feedback.
Regards,

-JJ

ps. somehow the filter is not applied if lines are drawn with markers
which is very weird.
Attachment (agg_filter.diff): text/x-diff, 10 KiB
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Jouni K. Seppänen | 14 Jun 08:09
Face
Favicon
Gravatar

backend_driver.py

I just committed a change to backend_driver.py that allows running a
subset of all tests by directory. In the process I changed the command
line parsing to use OptionParser, but I tried to keep it reasonably
backward compatible. Here are the options the script now takes:

Options:
  -h, --help            show this help message and exit
  -d DIRS, --dirs=DIRS, --directories=DIRS
                        Run only the tests in these directories; comma-
                        separated list of one or more of: pylab (or
                        pylab_examples), api, units, mplot3d
  -b BACKENDS, --backends=BACKENDS
                        Run tests only for these backends; comma-separated
                        list of one or more of: agg, ps, svg, pdf, template,
                        cairo, cairo.png, cairo.ps, cairo.pdf, cairo.svg.
                        Default is everything except cairo.
  --clean               Remove result directories, run no tests
  -c, --coverage        Run in coverage.py
  -v, --valgrind        Run in valgrind

In addition to the list of backends given via the -b and --backends
options, any extra arguments are added to the list of backends, or
interpreted as switches to pass to the subprocess that runs each test.

--

-- 
Jouni K. Seppänen
http://www.iki.fi/jks

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects

Gmane