>>>>> "Jordan" == Jordan Dawe <[EMAIL PROTECTED]> writes:
Jordan> Ok, I have some questions about what the protocol for
Jordan> patch submission should be, in terms of 'completeness' of
Jordan> the patch.
Jordan> I have a patch for the quiver function that is half
Jordan> done... it has converted the arrows from patches to
Jordan> linecollections, and it will accept arbitrary X and Y
Jordan> coordinates for the arrow positions, as suggested by Rob.
Jordan> Unfortunetly, none of the color functionality is working.
Jordan> Partly this is because the color functionality of
Jordan> LineCollection is different from PolyCollection (which
Jordan> quiver originally used) and partly because I don't
Jordan> understand how matplotlib sets colors at all. Should I
Jordan> submit this half finished patch so that others can have a
Jordan> chance to improve the color function? Or should I not
Jordan> submit until I figure out how color works and fix the
Jordan> thing?
I don't recommend submitting patches that don't work. Rather, post
code samples here with questions in the areas you need help.
Jordan> Furthermore, can LineCollection actually do all the things
Jordan> that quiver's old color commands demand of it? I don't
Jordan> see a place to set a colormap for a LineCollection, but as
Jordan> I said, I don't understand it very well.
You can create a line collection that is color mappable by deriving
from LineCollection and ScalarMappable. It will take a little more
work to fully integrate it into the colormappable framework, eg so
colorbars and interactive changing of colormaps works as expected, but
this may be enough to speed you along
This is a good example of how you can extend and specialize the
existing classes if they don't behave like you want them to.
from matplotlib.colors import normalize
from matplotlib.cm import ScalarMappable, jet
from matplotlib.collections import LineCollection
from pylab import figure, show, nx
class LineCollectionSM(LineCollection, ScalarMappable):
def __init__(self,
segments,
x,
norm,
cmap,
# and the other args for LineCollection
):
LineCollection.__init__(self, segments)
ScalarMappable.__init__(self, norm, cmap)
self.set_array(x)
def draw(self, renderer):
self._colors = self.to_rgba(self.get_array())
LineCollection.draw(self, renderer)
def random_segment():
x1, y1, x2, y2 = nx.mlab.rand(4)
return (x1, y1), (x2, y2)
segments = [random_segment() for i in range(50)]
x = nx.mlab.rand(50)
col = LineCollectionSM(segments, x, normalize(), jet)
fig = figure()
ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1), autoscale_on=False)
ax.add_collection(col)
show()
-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel