Hello,
i'm trying to use matplotlib to draw some rectangles on one screen. Every
rectangle has is own position (x,y) is own size, and each of them must have a
fill color in a colormap.
Is there an example somewhere ?
Thank you.
···
######################################################################
Jean-Christophe Penalva
Easiest is to use a matplotlib.collections.PolyCollection, which is
already setup for colormapping::
import numpy as np
import matplotlib.collections as collections
import matplotlib.cm as cm
import matplotlib.pyplot as plt
N = 100
verts = [((x, y), (x, y+height), (x+width, y+height), (x+width,
y)) for (x,y,width,height) in np.random.rand(N,4)]
intensities = np.random.rand(N)
c = collections.PolyCollection(verts)
c.set_array(intensities)
c.set_cmap(cm.hot)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.add_collection(c)
ax.set_xlim(-1,2)
ax.set_ylim(-1,2)
plt.show()
JDH
···
On Tue, May 19, 2009 at 2:21 AM, Jean-Christophe Penalva <jean-christophe.penalva@...2612...> wrote:
i'm trying to use matplotlib to draw some rectangles on one screen. Every
rectangle has is own position (x,y) is own size, and each of them must have a
fill color in a colormap.
Is there an example somewhere ?