Re: [Matplotlib-users] plot order From: Rob Hetland - 2008-01-24 07:32 ```On Jan 24, 2008, at 8:11 AM, Jordan Dawe wrote: > However, when I do this the result is the two contour plots are > drawn on > top of the contourf plots no matter what. How do I hide the contours > under a contourf? zorder. It won't really matter what order you plot, as long as you set the zorder of the objects to the order you want. However, there is no set_zorder for the whole contour, rather just for each element in the collection. Observe: pc = contour(random.rand(10,10)) pcf = contourf(random.rand(10,10), cmap=cm.gray) # now the contours are on top for l in pc.collections: l.set_zorder(-100) draw() # now the contours are on the bottom I guess the advantage is that you could pick and choose which contours to expose: for l in pcf.collections[::2]: l.set_zorder(-1000) draw() # woven contours and contourfs... -Rob ---- Rob Hetland, Associate Professor Dept. of Oceanography, Texas A&M University http://pong.tamu.edu/~rob phone: 979-458-0096, fax: 979-845-6331 ```

 Re: [Matplotlib-users] plot order From: Rob Hetland - 2008-01-24 07:32 ```On Jan 24, 2008, at 8:11 AM, Jordan Dawe wrote: > However, when I do this the result is the two contour plots are > drawn on > top of the contourf plots no matter what. How do I hide the contours > under a contourf? zorder. It won't really matter what order you plot, as long as you set the zorder of the objects to the order you want. However, there is no set_zorder for the whole contour, rather just for each element in the collection. Observe: pc = contour(random.rand(10,10)) pcf = contourf(random.rand(10,10), cmap=cm.gray) # now the contours are on top for l in pc.collections: l.set_zorder(-100) draw() # now the contours are on the bottom I guess the advantage is that you could pick and choose which contours to expose: for l in pcf.collections[::2]: l.set_zorder(-1000) draw() # woven contours and contourfs... -Rob ---- Rob Hetland, Associate Professor Dept. of Oceanography, Texas A&M University http://pong.tamu.edu/~rob phone: 979-458-0096, fax: 979-845-6331 ```
 Re: [Matplotlib-users] plot order From: Jordan Dawe - 2008-01-24 16:31 ```> > pc = contour(random.rand(10,10)) > pcf = contourf(random.rand(10,10), cmap=cm.gray) > # now the contours are on top > > for l in pc.collections: > l.set_zorder(-100) > > draw() > # now the contours are on the bottom Well, that's certainly kludgey, but it worked great. Thanks. Jordan ```
 Re: [Matplotlib-users] plot order From: Eric Firing - 2008-01-24 18:13 ```Jordan Dawe wrote: >> pc = contour(random.rand(10,10)) >> pcf = contourf(random.rand(10,10), cmap=cm.gray) >> # now the contours are on top >> >> for l in pc.collections: >> l.set_zorder(-100) >> >> draw() >> # now the contours are on the bottom > > Well, that's certainly kludgey, but it worked great. Thanks. Maybe contour, contourf, and any similar plotting commands that do not support zorder as a kwarg should do so? I am not sure if this is needed often enough to warrant the extra code and documentation. Eric ```
 Re: [Matplotlib-users] plot order From: Jordan Dawe - 2008-01-24 18:25 ```Eric Firing wrote: > > Maybe contour, contourf, and any similar plotting commands that do not > support zorder as a kwarg should do so? I am not sure if this is > needed often enough to warrant the extra code and documentation. I can't speak for other people, but I use this kind of functionality in nearly every plot I do. Usually I contourf a field in 4-level greyscale, then contour over that to make 8 contour levels, then contourf over _that_ to mask land points (I run models so I have 'land' arrays I can use for this). Sometimes I them put polygons (sometimes transparent) over that to highlight regions. Usually how I've been doing this is by going in to illustrator and manually altering the stacking of the plot elements. Ideally how I wish it worked was that the default zorder was set by a counter, so the oldest plots on an axis would be buried under the newer ones. Jordan ```