1 | initial version |
The problem is that a region_plot
is really just a contour plot with exactly two colored regions. The "inside" color is determined by incolor
, and the "outside" is determined by outcolor
. Now here's the key: outcolor
is white by default, so you might think that the outside of the region is transparent. But it's not. That explains why you only see one of the two plots -- the top one is completely opaque, thus covering the bottom one. This also explains why you get different results when you sum the two plots in different orders -- this changes which one is on top.
Now here's a fix: just use contour_plot
directly. To do this, define a function which will separate the regions you're interested in. For example:
def sep(x,y):
if 2*x < y:
return 1
if x < y and y <= 2*x:
return 0
if y <= x:
return -1
Now make the contour plot, choosing contour lines between your separate outputs, and listing the colors you want:
contour_plot(sep, (x,0,2), (y,0,2), plot_points=400, contours=[-.5,.5], cmap=['white','red','blue'])
2 | No.2 Revision |
The problem is that a region_plot
is really just a contour plot with exactly two colored regions. The "inside" color is determined by incolor
, and the "outside" is determined by outcolor
. Now here's the key: outcolor
is white by default, so you might think that the outside of the region is transparent. But it's not. That explains why you only see one of the two plots -- the top one is completely opaque, thus covering the bottom one. This also explains why you get different results when you sum the two plots in different orders -- this changes which one is on top.
Now here's a fix: just use contour_plot
directly. To do this, define a function which will separate the regions you're interested in. For example:
def sep(x,y):
if 2*x < y:
return 1
if x < y and y <= 2*x:
return 0
if y <= x:
return -1
Now make the contour plot, choosing contour lines between your separate outputs, and listing the colors you want:
contour_plot(sep, (x,0,2), (y,0,2), plot_points=400, contours=[-.5,.5], cmap=['white','red','blue'])
Also note that contour_plot
will probably work pretty well without you explicitly specifying the contours or the colors, if you don't want to worry about that step.