Hi: I attach a pcolor plot. I would like to get rid of the
> areas outside the larger circle and inside the smaller
> circle. Ideally I would like them to be white. Currently I
> create my plot using pcolor and then plot *lots* of white
> circles (for the inside) and lines (for the outside) on
> top, to get rid of the unwanted areas. This works but I
> wonder whether there is a better/faster solution. I would
> imagine I could set the values corresponding to the
> unwanted areas to some particular color before I call
> pcolor, but the issue is that I want those ares to be white
> (or other color not included in the standard palette which
> is used for plotting the area inside the annulus). Can this
> be done?
Inside the circle is easy - just set the facecolor of the circle to be
white 'w', or whatever rgb tuple you want. How are you creating the
circles, with plot, scatter, or instantiating your own Circle
instances?
Outside the circle requires implementing general clipping, which will
be done but I can't say how soon right now. What backend are you
using? The circles don't look antialiased so I'm guessing not agg.
agg and postscript are probably the best bets for getting general
clipping support first.
Another question: is there a reason you are using pcolor rather than
imshow? imshow will give you the same result with interpolation and
dramatic performance benefits. Since you aren't using faceted shading
or otherwise tweaking the pcolor rectangles, you don't gain anything
by using pcolor unless you need a backend that doesn't support imshow
yet (gd?)
> Another question is in regards to showing tics in pcolor
> plots. In my "legend" on the right, I would like them to be
> visible, but they get overwritten. I suppose I could plot
> each manually after I do pcolor; is it how this is meant to
> be done?
This is an easy fix. Basically you just need to move the axis drawing
to the end of the axes drawing code. Currently it is done before any
before any lines or patches are drawn. Try replacing
matplotlib.Axes._draw with the code below.
I'll make a deal: if you contribute some code to produce the nice
color legend you made, I'll try and implement general clipping!
JDH
def _draw(self, renderer, *args, **kwargs):
"Draw everything (plot lines, axes, labels)"
if not ( self.xaxis.viewlim.defined() and
self.yaxis.viewlim.defined() ):
self.update_viewlim()
if self.axison:
if self._frameon: self._axesPatch.draw(renderer)
if self._image is not None:
self._image.draw(renderer)
for p in self._patches:
p.draw(renderer)
for line in self._lines:
line.draw(renderer)
for t in self._text:
t.draw(renderer)
self._title.draw(renderer)
if 0: bbox_artist(self._title, renderer)
# optional artists
for a in self._artists:
a.draw(renderer)
if self._legend is not None:
self._legend.draw(renderer)
for table in self._tables:
table.draw(renderer)
if self.axison:
self.xaxis.draw(renderer)
self.yaxis.draw(renderer)