3
$\begingroup$

I've written the following code and it works well; however, I've tried (to no avail) to highlight in white the Log[5] contour inside the SliceContourPlot3D. My code is below. It works well separately. Can this be combined into the 3D plot? Ideas welcomed!

f[p_, x_] := p*Log[7] + (1 - p)*Log[x];
AA = Show[
  Plot3D[f[p, x], {p, 0, 1}, {x, 3, 7}, Mesh -> None, 
   PlotStyle -> Directive[Opacity[0.75], Specularity[White, 50]], 
   ColorFunction -> "Rainbow", PlotTheme -> "Detailed", 
   FaceGrids -> None, 
   LabelStyle -> {FontFamily -> "Arial", FontSize -> 12, Black}], 
  SliceContourPlot3D[f[p, x], 
   z == 1.1, {p, 0, 1}, {x, 3, 7}, {z, 0, 2}, 
   ColorFunction -> "Rainbow", Boxed -> False]]
BB = Show[
  ContourPlot[f[p, x], {p, 0, 1}, {x, 3, 7}, 
   ColorFunction -> "Rainbow"], 
  ContourPlot[f[p, x] == Log[5], {p, 0, 1}, {x, 3, 7}, 
   ContourStyle -> {Thick, White}]]
$\endgroup$

2 Answers 2

4
$\begingroup$
highlight = 
  SliceContourPlot3D[f[p, x], 
   z == 1.1, {p, 0, 1}, {x, 3, 7}, {z, 0, 2}, 
   ColorFunction -> "Rainbow", Boxed -> False, Contours -> {Log[5]}, 
   ContourStyle -> Directive[AbsoluteThickness[5], White], 
   ContourShading -> None];
Show[AA, highlight]

enter image description here

$\endgroup$
1
  • $\begingroup$ nice! I seehow you have Contours->Log[5] here -- very nice!! ... thank u so much! $\endgroup$
    – user42700
    Apr 17, 2023 at 1:57
5
$\begingroup$

Extract the automatically generated list of contour levels from ContourPlot

cl = Cases[ContourPlot[f[p, x], {p, 0, 1}, {x, 3, 7}], Tooltip[_, t_] :> t, All];

Append cl with desired contour levels and styles and use it as the option setting for Contours in SliceContourPlot3D:

SliceContourPlot3D[f[p, x], z == 1.1, {p, 0, 1}, {x, 3, 7}, {z, 0, 2}, 
 ColorFunction -> "Rainbow", Boxed -> False, 
 Contours -> Append[cl, {Log[5.], Directive[Thick, White]}]]

enter image description here

$\endgroup$
1
  • $\begingroup$ I like this view too as it provides a clear view of the height of the floor above zero, which you can control with z =1.1, or z= 1.5, etc. Thank you for sharing your skills kglr!! $\endgroup$
    – user42700
    Apr 17, 2023 at 2:06

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.