## matplotlib-users

 [Matplotlib-users] scatter and Polygon From: Willi Richert - 2006-11-20 13:08:42 ```Hi, how can I draw the scatter squares in front of the Polygon? from pylab import * x,y = zip(*randn(10,2)) ax=subplot(111) xRange=(-10,10) yRange=xRange poly = Polygon([(xRange[0], yRange[0]), (xRange[0], yRange[1]), (0, yRange[1]), (0, yRange[0])], facecolor='0.7', edgecolor='0.6', alpha=0.0) ax.add_patch(poly) ax.scatter(x,y, color="b", s=150, marker="s", alpha=0.2) show() Regards, wr ```
 Re: [Matplotlib-users] scatter and Polygon From: John Hunter - 2006-11-20 15:15:52 ```>>>>> "Willi" == Willi Richert writes: Willi> Hi, how can I draw the scatter squares in front of the Willi> Polygon? Set the zorder of the PolyCollection (what scatter uses) to be higher than the zorder of the Polygon col = ax.scatter(x,y, color="b", s=150, marker="s", alpha=0.2, zorder=Polygon.zorder+1) JDH ```
 Re: [Matplotlib-users] scatter and Polygon From: Willi Richert - 2006-11-21 08:20:50 ```Am Montag, 20. November 2006 16:15 schrieb John Hunter: > >>>>> "Willi" == Willi Richert writes: > > Willi> Hi, how can I draw the scatter squares in front of the > Willi> Polygon? > > Set the zorder of the PolyCollection (what scatter uses) to be higher > than the zorder of the Polygon > > col = ax.scatter(x,y, color="b", s=150, marker="s", alpha=0.2, > zorder=Polygon.zorder+1) > > > JDH Thanks, that solved that problem, but if I use 'label="blabla"' in scatter, it does not show up in the legend. Only the label of the Polygon is shown. wr ```
 Re: [Matplotlib-users] scatter and Polygon From: John Hunter - 2006-11-21 16:44:50 ```>>>>> "Willi" == Willi Richert writes: Willi> Thanks, that solved that problem, but if I use Willi> 'label="blabla"' in scatter, it does not show up in the Willi> legend. Only the label of the Polygon is shown. There was a bug in the axes autolegend code that was preventing scatter from being picked up but I have fixed it in svn. Note that automatically making a legend entry with scatter is a bit problematic, since scatter can use many different colors. We have a poor-man's compromise, which is to make a rectangle the sample color as the first scatter point plotted. JDH ```