2
$\begingroup$

How to convert this RegionPlot3D to a DensityPlot having z as the colour axis, here is one code sample

  RegionPlot3D[{10^y < 10^23*10^(z - x), 10^y > 10^25 10^-x , 10^y > 10^26*10^-x , 10^y < 
  10^57*10^(-2 x + 4 z/3), 10^y > 10^-164*10^(-8 z + 5 x)}, {x, 28, 31}, {y, -8, 
  1}, {z, -3, -1}, ColorFunction -> "Rainbow", Mesh -> None, 
  Axes -> {True, True, True}, PlotLegends -> BarLegend[Automatic]]

For simplicity, if you try to plot a 2D region of x vs z varying y from -8 to 1 you will see a parametric shifting of a triangular region. I need to superimpose all those regions with varying colours to a single plot and add the colour axis y to show the parametric change. An example of this can be seen if one can superimpose the different coloured circles to the same plot showing the change by a colour axis a. Example:

 Manipulate[
 RegionPlot[(x - a)^2 + y^2 < 1, {x, -2, 2}, {y, -2, 2}, 
  ColorFunction -> Function[{x, y}, Hue[a]]], {a, 0, 1}]
$\endgroup$
2
  • $\begingroup$ Five HalfSpaces : ineqs = {10^y < 10^23*10^(z - x), 10^y > 10^25 10^-x, 10^y > 10^26*10^-x, 10^y < 10^57*10^(-2 x + 4 z/3), 10^y > 10^-164*10^(-8 z + 5 x)}; ineqs = ineqs /. Power[10, expr_] :> expr $\endgroup$
    – cvgmt
    May 6, 2023 at 15:05
  • $\begingroup$ @cvgmt I understood your point my equations are unnecessarily complicated by 10^, but is it possible to get the allowed region by the halfspaces as a 2D DensityPlot. $\endgroup$ May 7, 2023 at 4:55

1 Answer 1

3
$\begingroup$

We can retrieve data directly from RegionPlot3D. In this case there are 5 regions combined in one plot. Therefore we need 5 plots to convert 3D in 2D. First step

R=RegionPlot3D[{10^y < 10^23*10^(z - x), 10^y > 10^25 10^-x, 
  10^y > 10^26*10^-x, 10^y < 10^57*10^(-2 x + 4 z/3), 
  10^y > 10^-164*10^(-8 z + 5 x)}, {x, 28, 31}, {y, -8, 
  1}, {z, -3, -1}, ColorFunction -> "Rainbow", Mesh -> None, 
 Axes -> {True, True, True}, PlotLegends -> BarLegend[Automatic]]

Second step

data[i_] := R[[1, 1, 1, i]][[1]];

Visualization

{R, Table[
  ListDensityPlot[data[i], PlotLegends -> Automatic, 
   FrameLabel -> {"x", "y"}, ColorFunction -> "Rainbow", 
   PlotRange -> All], {i, 5}]}

Figure 1

Update 1. To visualize regions in one plot we can use

n = Length[Range[-3, -1, 1/20]]; frame = 
 Table[RegionPlot[{10^y < 10^23*10^(z - x), 10^y > 10^25 10^-x, 
    10^y > 10^26*10^-x, 10^y < 10^57*10^(-2 x + 4 z/3), 
    10^y > 10^-164*10^(-8 z + 5 x)}, {x, 28, 31}, {y, -8, 1}, 
   PlotStyle -> RGBColor[1, 1, 1, 1/n], 
   BoundaryStyle -> {RGBColor[4/3 + (z/3), -z/3, 4/3 + z/3], 
     Thick}], {z, -3, -1, 1/n}];
Show[frame]

In this picture we can clearly recognize colored regions shown above Figure 2

We also can animate solution at different z as follows

frames = 
 Table[Show[Take[frame, i]], {i, Length[frame]}]; ListAnimate[frames]

Figure 3

$\endgroup$
9
  • $\begingroup$ Thank you, for your nice try. I really appreciate it. I have updated my question a bit to make it more easily understandable. I think it will be a perfect 2D map if one superimposes all those regions with varying colours to a single plot and add the colour axis $\endgroup$ May 7, 2023 at 9:51
  • $\begingroup$ @darkknight Do you mean Manipulate[ RegionPlot[{10^y < 10^23*10^(z - x), 10^y > 10^25 10^-x, 10^y > 10^26*10^-x, 10^y < 10^57*10^(-2 x + 4 z/3), 10^y > 10^-164*10^(-8 z + 5 x)}, {x, 28, 31}, {y, -8, 1}, ColorFunction -> Function[{x, y}, Hue[z]]], {z, -3, -1}] ? $\endgroup$ May 7, 2023 at 10:47
  • $\begingroup$ yes I do mean the parametric variation of the triangular allowed region with z but instead of Manipulate I want to get the triangular region in a single saveable image as a temperature map where the colour axis (z) will indicate the change of the area of the triangle with z. $\endgroup$ May 7, 2023 at 11:14
  • $\begingroup$ @darkknight It is possible with lines only, not with solid colors. Since regions have intersections. $\endgroup$ May 8, 2023 at 5:06
  • $\begingroup$ yes, you are correct. But I need a region like this but it will be better if the region lines become invisible, then it may look like a temperature map $\endgroup$ May 8, 2023 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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