1
$\begingroup$

I want to combine 2D Plot with 3D Plot, where the 2D Plot should be placed on one of the "walls" of the 3D Plot. I have used an idea from this answer and ended with something like that (where the functions are only some example without a meaning)

p1 = Plot3D[Sin[d+s] - Cos[s], {s, 0, Pi}, {d, 0, Pi}, 
   PlotRange -> {0, 1}, AxesLabel -> {"s", "d", "Sin[d+s]-Cos[s]"}, 
   AxesStyle -> Directive[Black, 20]];
p2 = Plot[{(t/Pi)^2, Sqrt[t/Pi]}, {t, 0, Pi}, 
   PlotStyle -> {Black, Blue}];
p3 = Graphics3D @@ (FullGraphics[p2] /. 
     Line[pts__] :> Line[pts /. {s_, d_} :> {s, 0, d}]);
Show[p1, p3]

I think the plot I obtain is fine, however, I got also some Axes and Ticks errors and the whole background is red, even if I turn the errors off.

What do I wrong?

$\endgroup$
2
  • 1
    $\begingroup$ The problem comes from FullGraphics[p2]. p2 is a list of length 2. The first elements contains all the graphics primitives, the second the options. FullGraphics has problems with the options. Therefore, write FullGraphics[p2[[1]]] $\endgroup$ Oct 29, 2020 at 12:04
  • $\begingroup$ Great, it works! Many thanks! $\endgroup$
    – Agnieszka
    Oct 29, 2020 at 12:07

1 Answer 1

1
$\begingroup$

We can also directly draw the two 3D curves by use ParametricPlot3D,

{x, y, z} /. {x -> t, y -> 0, z -> (t/Pi)^2}
{x, y, z} /. {x -> t, y -> 0, z -> Sqrt[t/Pi]}
p1 = Plot3D[Sin[d + s] - Cos[s], {s, 0, Pi}, {d, 0, Pi}, 
   PlotRange -> {0, 1}, AxesLabel -> {"s", "d", "Sin[d+s]-Cos[s]"}, 
   AxesStyle -> Directive[Black, 20]];
p4 = 
   ParametricPlot3D[{{x, y, z} /. {x -> t, y -> 0, z -> (t/Pi)^2}, {x,
        y, z} /. {x -> t, y -> 0, z -> Sqrt[t/Pi]}}, {t, 0, Pi}, 
    PlotStyle -> {Black, Blue}];
Show[p1, p4]
$\endgroup$

Your Answer

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

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