1
$\begingroup$

I am trying to combine 2D SmoothDensityHistogram and 3D curve. This is my histogram code

a = SmoothDensityHistogram[tabS2S1, Automatic, "PDF",
  ColorFunction -> (Blend[{White, Hue[2/3]}, #] &),
  PlotRange -> {{0.30, -0.05}, {-60, 120}}, 
  FrameTicks -> False,
  FrameStyle -> Directive[Black, Thick]
  ]

It shows

enter image description here

Here is my 3D curve code

Show[
 Graphics3D[{Thickness[0.007], Blue, 
   BSplineCurve[tab1, SplineDegree -> 3]}],
 PlotRange -> {{-0.05, 0.3}, {-60, 120}, {-2, 7}}, 
 BoxRatios -> {2.0, 2.0, 1.5},
 Axes -> True,
 AxesStyle -> {Thick, Thick, Thick}, 
 AxesEdge -> {{-1, -1}, {1, -1}, {-1, -1}},
 LabelStyle -> {FontSize -> 50, FontFamily -> "Times", 
   FontColor -> "black" },
 ImageMargins -> 1.5, ImageSize -> 1800,
 Boxed -> False,
 FaceGrids -> {
   {{0, 0, -1}, {{-0.1, -0.05, 0, 0.05, 0.10, 0.15, 0.20, 
      0.25}, {-180, -150, -120, -90, -60, -30, 0, 30, 60, 90, 120, 
      150, 180}}},
   {{-1, 0, 0}, {{-30, 0, 30, 60, 90, 120}, {0, 1, 2, 3, 4, 5, 6}}}
   }

And it shows enter image description here

I want to project the histogram picture on the bottom of 3D curve where Z=-2.

Could anyone help me?

$\endgroup$
1
  • 1
    $\begingroup$ You should provide some data for tab1 and tabS2S1. $\endgroup$
    – flinty
    Commented Jul 31, 2020 at 12:55

1 Answer 1

1
$\begingroup$

You could project the texture of the density onto a Polygon. I will leave it to you to figure out the details of your plot ranges and getting the curve on this plot, as I do not have your data to try myself.

It is important that the density image has no PlotRangePadding and that the PlotRange matches up with your Graphics3D:

SeedRandom[123];
sdhtexture = 
 SmoothDensityHistogram[
   RandomVariate[NormalDistribution[0, 1], {100, 2}], Frame -> None, 
   PlotRangePadding -> None, 
   ColorFunction -> Function[{z}, RGBColor[1 - z, 1 - z, 1]]] // Image

Graphics3D[{Texture[sdhtexture], Opacity[.7],EdgeForm[None],
  Polygon[{{0, -50, -2}, {0, 100, -2}, {0.3, 
     100, -2}, {0.3, -50, -2}}, 
   VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]
  }, PlotRange -> {{0, 0.3}, {-50, 100}, {-2, 6}}, BoxRatios -> 1, 
 Boxed -> False, 
 FaceGrids -> {{{0, 
     0, -1}, {{-0.1, -0.05, 0, 0.05, 0.10, 0.15, 0.20, 
      0.25}, {-180, -150, -120, -90, -60, -30, 0, 30, 60, 90, 120, 
      150, 180}}}, {{-1, 0, 
     0}, {{-30, 0, 30, 60, 90, 120}, {0, 1, 2, 3, 4, 5, 6}}}},
 Lighting -> "Neutral"]

projected density image

$\endgroup$

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.