4
$\begingroup$

I use this code

RegionPlot[
 Sin[t^(1/3)*y] > 0, {y, 0, 5}, {t, 0, 8}, 
 FrameLabel -> {"y", Rotate["t", 270 Degree]}]

and the result is

output from RegionPlot

Now, I have three questions:

  1. How can I move the $y$ axis (and tick labels) to the top instead of bottom?
  2. How can I change the color of border lines?
  3. Is it possible to change the color of one of the blue portions of the region?
$\endgroup$
3
$\begingroup$
  1. You can use Frame -> All and make the unwanted tick labels invisible using FontOpacity -> 0 in corresponding FrameTicksStyle

  2. Use the option BoundaryStyle

  3. Post-process the output from RegionPlot with the above options to construct polygons with desired colors from the boundary lines using ReplaceAll[l_Line] :> {l, desiredstyle, Polygon @@l}] or ReplaceAll[l_Line] :> {l, desiredstyle, FilledCurve @ l}].

rp = RegionPlot[Sin[t^(1/3)*y] > 0, {y, 0, 5}, {t, 0, 8}, 
   FrameLabel -> {{"t", None}, {None, "y"}}, 
   RotateLabel -> False,
   FrameTicks -> All, 
   FrameTicksStyle -> {{Automatic, Automatic}, {FontOpacity -> 0, Automatic}}, 
   PlotPoints -> 100,
   BoundaryStyle -> Directive[Thick, Red]];

Use a random color for each sub-region:

SeedRandom[777]
rp /. l_Line :> {l, RandomColor[], Polygon @@ l}

enter image description here

Use a built-in color scheme (say, ColorData[97]) to color subregions:

Module[{i = 1}, rp /. l_Line :> {l, ColorData[97][i++], Polygon @@ l}]

enter image description here

Use your preferred list of colors:

colors = {LightBlue, Green}; 

rp  /. l_Line :> {l, Last[colors = RotateLeft[colors]], Polygon @@ l}

enter image description here

The first two methods work with arbitrary number of subregions. Method 3 cycles through the colors in input color list. If you want a different color for each subregion, the length of the list of colors should match the number of subregions.

For example, for the case with {y, 0, 10} (instead of {y, 0, 5}), the three methods give:

SeedRandom[777]
rp /. l_Line :> {l, RandomColor[], Polygon @@ l}

enter image description here

Module[{i = 1}, rp /. l_Line :> {l, ColorData[97][i++], Polygon @@ l}]

enter image description here

colors = {LightBlue, Green};
rp /. l_Line :> {l, Last[colors = RotateLeft[colors]], Polygon @@ l}

enter image description here

Using colors = {LightBlue, Green, Magenta, Orange}; we get:

enter image description here

Additional examples:

rp1 = RegionPlot[Sin[x] Sin[y] > 1/10, {x, -3 Pi, 3 Pi}, {y, -3 Pi, 3 Pi}, 
   BoundaryStyle -> Red, ImageSize -> Medium, FrameTicks -> None];

rp2 = RegionPlot[3 >= Evaluate[Sum[Cos[RandomReal[4, 2].{x, y}], {3}]] > 1/4, 
   {x, -10, 10}, {y, -10, 10}, 
   BoundaryStyle -> Red, ImageSize -> Medium, FrameTicks -> None];

Grid[{{rp1, 
   rp1 /. l_Line :> {AbsoluteThickness[5], Darker[rc = RandomColor[]],
       l, rc, FilledCurve @ l}},
  {rp2, rp2 /. 
    l_Line :> {AbsoluteThickness[5], Darker[rc = RandomColor[]],  
      l, rc, FilledCurve @ l}}}]

enter image description here

$\endgroup$
2
$\begingroup$

I can not find a elegant method to do this.Here just a temporary way.

RegionPlot[{Sin[t^(1/3)*y] > 0 && 2 π < t^(1/3)*y < 3 π,
    Sin[t^(1/3)*y] > 0 && 0 < t^(1/3)*y < 2 π}, {y, 0, 5}, {t, 0, 
   8}, FrameLabel -> {{t, None}, {None, Style[y, Red]}}, 
  Frame -> True, FrameTicks -> {{All, None}, {None, All}}, 
  BoundaryStyle -> Cyan, PlotStyle -> {Brown, Pink}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.