[matplotlib-devel] axes.py scatter doc-bug

2008-03-12 Thread Manuel Metz
Hi,
the doc-string of the axes scatter method is buggy. Somehow the 
svn-conflict messages got committed to the repository:
I mean this

<<< .working
[...]
===
[...]
 >>> .merge-right.r4987

... stuff)

Manuel


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] blitting and byteswapping a buffer

2008-03-12 Thread Darren Dale

I discovered another blitting bug in backend_qt4agg.py. Qt expects a pixmap 
stringBuffer formatted in ARGB, but mpl formats in RGBA. The qt4 backend 
usually uses the _renderer.tostring_bgra method to return a properly 
formatted buffer:

if QtCore.QSysInfo.ByteOrder == QtCore.QSysInfo.LittleEndian:
stringBuffer = self.renderer._renderer.tostring_bgra()
else:
stringBuffer = self.renderer._renderer.tostring_argb()

The problem I am seeing is when we are blitting, and the tostring_bgra is not 
available. The blitting code in backend_qt4agg.py, starting around line 112, 
gets a buffer from a region copied from a bbox:

reg = self.copy_from_bbox(bbox)
stringBuffer = reg.to_string()
qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32)

reg does not have a method to swap the byte order, and Qt does not have a 
Format_RGBA32. Could anyone suggest how to swap the byte order?

Thanks,
Darren

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] LineCollection and alpha

2008-03-12 Thread Michael Fitzgerald
Hi all,
I found a small bug in LineCollection, which gives an exception when setting
alpha.  This is manifested in e.g. hlines and vlines:

In [1]: hlines((0,),(-1,),(1,),color='b',alpha=0.1)
---
IndexErrorTraceback (most recent call last)

XXX/ in ()

XXX/lib/python/matplotlib/pyplot.py in hlines(*args, **kwargs)
   1700 hold(h)
   1701 try:
-> 1702 ret =  gca().hlines(*args, **kwargs)
   1703 draw_if_interactive()
   1704 except:

XXX/lib/python/matplotlib/axes.py in hlines(self, y, xmin, xmax, colors,
linestyles, label, **kwargs)
   2609 linestyles=linestyles,
label=label)
   2610 self.add_collection(coll)
-> 2611 coll.update(kwargs)
   2612
   2613 minx = min(xmin.min(), xmax.min())

XXX/lib/python/matplotlib/artist.py in update(self, props)
438 if func is None or not callable(func):
439 raise AttributeError('Unknown property %s'%k)
--> 440 func(v)
441 changed = True
442 self.eventson = store

XXX/lib/python/matplotlib/collections.py in set_alpha(self, alpha)
306 else:
307 artist.Artist.set_alpha(self, alpha)
--> 308 self._facecolors[:, 3] = alpha
309 self._edgecolors[:, 3] = alpha
310

IndexError: invalid index



This appears to be because LineCollection.__init__() only uses
Collection._edgecolors, and sets _facecolors to an empty array.  I don't
know if it's the proper solution, but I did this to get it to work:

Index: lib/matplotlib/collections.py
===
--- lib/matplotlib/collections.py   (revision 5000)
+++ lib/matplotlib/collections.py   (working copy)
@@ -305,7 +305,8 @@
 except TypeError: raise TypeError('alpha must be a float')
 else:
 artist.Artist.set_alpha(self, alpha)
-self._facecolors[:, 3] = alpha
+if len(self._facecolors):
+self._facecolors[:, 3] = alpha
 self._edgecolors[:, 3] = alpha

 def get_linewidths(self):


Best,
Mike
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] basemap drawcoastlines: suppress legend label

2008-03-12 Thread Eric Firing
Jeff,

When putting a legend on a basemap plot, I find that the legend command 
picks up the coastline line collection and gives it an uninformative 
label.  I suspect this is rarely what one wants.  Two suggestions:

1) In drawcoastlines, use "coastlines.set_label('_nolabel_') to suppress 
inclusion in the legend, and similarly for drawcountries, etc.

2) Make drawcoastlines return the line collection that it creates. 
Similarly, drawcountries could return the line collection, 
fillcoastlines could return the list of patches, etc.  Drawparallels and 
drawmeridians are a little more complicated because they make the labels 
as well as the lines, so I am not sure what to do with them.

Granted, one can grab the reference to the line collection from the end 
of ax.collections, but it seems cheap, reasonable, and more convenient 
to simply have it returned by the command that makes it.

Eric


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel