Ok, I have some questions about what the protocol for
> patch submission should be, in terms of 'completeness' of
> the patch.
> I have a patch for the quiver function that is half
> done... it has converted the arrows from patches to
> linecollections, and it will accept arbitrary X and Y
> coordinates for the arrow positions, as suggested by Rob.
> Unfortunetly, none of the color functionality is working.
> Partly this is because the color functionality of
> LineCollection is different from PolyCollection (which
> quiver originally used) and partly because I don't
> understand how matplotlib sets colors at all. Should I
> submit this half finished patch so that others can have a
> chance to improve the color function? Or should I not
> submit until I figure out how color works and fix the
I don't recommend submitting patches that don't work. Rather, post
code samples here with questions in the areas you need help.
> Furthermore, can LineCollection actually do all the things
> that quiver's old color commands demand of it? I don't
> see a place to set a colormap for a LineCollection, but as
> 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):
# and the other args for LineCollection
ScalarMappable.__init__(self, norm, cmap)
def draw(self, renderer):
self._colors = self.to_rgba(self.get_array())
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)