On Jul 13, 8:35 pm, David Sanders <dpsand...@gmail.com> wrote:
> On Jul 13, 4:47 pm, Jason Grout <jason-s...@creativetrax.com> wrote:
>
>
>
> > On 7/13/10 4:46 AM, David Sanders wrote:
>
> > > Hi,
>
> > > I need to superimpose several region_plot's. These have regions
> > > colored in different colors which may or may not overlap. However, if
> > > I do something like
>
> > > var('p q')
> > > plot1 = region_plot([p+q<1, p+q>-1], (p,-2,2), (q,-2,2), incol='red')
> > > plot2 = region_plot([p-q<1, p-q>-1], (p,-2,2), (q,-2,2), incol='blue')
> > > show(plot1+plot2)
>
> > > then I see at most the outline of the first plot. It seems that the
> > > second plot covers up the first plot, since the default value of
> > > outcol is 'white'.
>
> > > Is there any way to make these plots transparent (i.e. with an alpha
> > > value less than 1), or at least not opaque? I tried putting the
> > > option
>
> > > outcol=None
>
> > > but this is not accepted. This would seem to me to be the first way of
> > > solving the issue.
>
> > > I had a look at the code for region_plot, which I at least understand
> > > the idea of. It uses matplotlib for the graphics, so perhaps the
> > > question of transparency is a matplotlib question. Nonetheless, I
> > > believe that matplotlib does have this capability, so this should be
> > > possible...!
>
> > It seems that adding transparency is a natural way to do this.  I've
> > posted a rough patch to do this up 
> > athttp://trac.sagemath.org/sage_trac/ticket/9491
>
> > I've also attached a figure resulting from:
>
> > var('p q')
> > plot1 = region_plot([p+q<1, p+q>-1], (p,-2,2), (q,-2,2), incol='red',
> > opacity=0.5)
> > plot2 = region_plot([p-q<1, p-q>-1], (p,-2,2), (q,-2,2), incol='blue',
> > opacity=0.5)
> > show(plot1+plot2)
>
> Exactly what I had in mind, thanks!
>
> David.
>
>
>
> > Sorry I don't have right now to finish the patch and ask for review; I'm
> > rushing out the door.

I have been playing with this a bit, and have found some problems.

Firstly, with this code it seems not to be possible to make a
region_plot *without* specifying opacity -- it looks like a default
argument is missing somewhere.

But the main problem is the same one as I started with. Currently,
each region_plot paints the part which is not "inside" the region in
white (by default), as opposed to leaving it "blank". This means that
when opacity != 0.5, the second plot drawn still partially hides the
first.

My preferred behaviour would be simply to not draw anything if, for
example, outcol == None.

Perhaps this is not the right place for this discussion (is that the
sage-devel list?), but I tried to modify the code to do this, by
checking for outcol as follows:

if outcol:
        g.add_primitive(ContourPlot(xy_data_array, xrange,yrange,
                                dict(contours=[-1e307, 0, 1e307],
cmap=cmap, fill=True, **options)))
else:
        g.add_primitive(ContourPlot(xy_data_array, xrange,yrange,
                                dict(contours=[-1e307, 0], cmap=cmap,
                                fill=True, **options)))

(I also checked for it where it is converted to an rgbcolor.)

So if outcol==None, then it should only fill the negative region,
which corresponds to where the arguments are true.

However, I never got this to work, apparently because I don't
understand properly what the cmap object does and how it works.
Directly in matplotlib I did manage to do what I wanted, but not
specifying a cmap. Here I can't seem to get it quite right, but it
seems to me like this is the right direction to go in.

Can somebody enlighten me on cmap?

Thanks,
David.




>
> > Thanks,
>
> > Jason
>
> >  regionplot.png
> > 27KViewDownload

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to