# 3D graphics overlaying with show function

**URL:** <https://community.wolfram.com/t/3d-graphics-overlaying-with-show-function/23053>\
**Category:** Questions\
**Tags:** graphics-and-visualization\
**Created:** [November 7, 2023, 6:45am UTC](https://community.wolfram.com/t/3d-graphics-overlaying-with-show-function/23053 "2023-11-07T06:45:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![yangjh](https://avatars.discourse-cdn.com/v4/letter/y/3e96dc/32.png) [@yangjh](https://community.wolfram.com/u/yangjh)\
**Post date:** [November 7, 2023, 6:45am UTC](https://community.wolfram.com/t/3d-graphics-overlaying-with-show-function/23053/1 "2023-11-07T06:45:21Z")

</div>

I’d like to combine 3D curve and surface with Show in Mathematica 13.3. It is strange that the curve could not be hiden by the surface effectively even though the curve is behind the surface. The code is given as following,

```
\[CurlyPhi] = \[Pi] {1/4, 1/2, 3/4};
x[t_] := 2 + Cos[t];
z[t_] := Sin[t];
g1 = RevolutionPlot3D[{x[t], z[t]}, {t, 0, 2 \[Pi]}, {\[Phi], 0, 
    2 \[Pi]}, PlotPoints -> 100, Mesh -> None];
g2 = Table[
   ParametricPlot3D[{x[t] Cos[\[CurlyPhi][[i]]], 
     x[t] Sin[\[CurlyPhi][[i]]], z[t]}, {t, 0, 2 \[Pi]}], {i, 3}];
Show[g2, g1, ViewVector -> {{2.8, 0, 0}, {0, 2.5, 0}}, 
 ViewAngle -> 70 °, Boxed -> False, Axes -> False, PlotRange -> All]

```

The result is shown in the attached figure. Beside that there is no different If the curve is replaced by Mesh method as mesh thickness is set explicitly.

 ![08.png](https://global.discourse-cdn.com/wolfram/original/2X/2/2a19dc5a1a7644496a14e5c35d135dbf5b6029ab.png)

---

<div class="post-metadata">

**Author:** ![henrikschachner](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/henrikschachner/32/32119_2.png) [@henrikschachner](https://community.wolfram.com/u/henrikschachner)\
**Post date:** [November 7, 2023, 1:35pm UTC](https://community.wolfram.com/t/3d-graphics-overlaying-with-show-function/23053/2 "2023-11-07T13:35:15Z")

</div>

I guess the problem is the mixing of objects of different dimensions. If you use a `Tube[]` instead of a `Line[]` it seems to work correctly. I would do it like so:

```
\[CurlyPhi] = \[Pi] {1/4, 1/2, 3/4};
x[t_] := 2 + Cos[t];
z[t_] := Sin[t];
g1 = RevolutionPlot3D[{x[t], z[t]}, {t, 0, 2 \[Pi]}, {\[Phi], 0, 2 \[Pi]}, PlotPoints -> 100, Mesh -> None, Axes -> False];
g2 = ParametricPlot3D[Table[{x[t] Cos[\[CurlyPhi][[i]]], x[t] Sin[\[CurlyPhi][[i]]], 
      z[t]}, {i, 3}], {t, 0, 2 \[Pi]}, PlotStyle -> Automatic] /. Line[p__] :> Tube[p, .05];
Show[g2, g1, Boxed -> False, Axes -> False, PlotRange -> All, ViewVector -> {{2.8, 0, 0}, {0, 2.5, 0}}, ViewAngle -> 70 °]

```

 ![TorusTubes.png](https://global.discourse-cdn.com/wolfram/original/2X/8/83187431344c45f66cbc1de3d0184f926c368836.png)

---

<div class="post-metadata">

**Author:** ![yangjh](https://avatars.discourse-cdn.com/v4/letter/y/3e96dc/32.png) [@yangjh](https://community.wolfram.com/u/yangjh)\
**Post date:** [November 7, 2023, 3:00pm UTC](https://community.wolfram.com/t/3d-graphics-overlaying-with-show-function/23053/3 "2023-11-07T15:00:36Z")

</div>

Thank you very much for your reply. Yes, it works good! But there is a new problem. If the radius of the tube is two small, it sames that the “curve” is dashed. For example, if to set Line[p\_\_] :\> Tube[p, .005], the result is showing in the attached figure. I don’t know how to deal with it as the radius of the tube should be fixed in my applying.

 ![tube.png](https://global.discourse-cdn.com/wolfram/original/3X/f/e/fe64b1936945cca8fb68605aedac4907d45597e8.png)

---

<div class="post-metadata">

**Author:** ![hansmilton](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/hansmilton/32/8656_2.png) [@hansmilton](https://community.wolfram.com/u/hansmilton)\
**Post date:** [November 7, 2023, 5:41pm UTC](https://community.wolfram.com/t/3d-graphics-overlaying-with-show-function/23053/4 "2023-11-07T17:41:06Z")

</div>

In Mathematica version 12.3 the rendering is as expected:

 ![Hiddencurves.png](https://global.discourse-cdn.com/wolfram/original/3X/e/0/e0cc93374b42029f56b9275d91146886914db9f6.png)

---

<div class="post-metadata">

**Author:** ![henrikschachner](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/henrikschachner/32/32119_2.png) [@henrikschachner](https://community.wolfram.com/u/henrikschachner)\
**Post date:** [November 7, 2023, 6:24pm UTC](https://community.wolfram.com/t/3d-graphics-overlaying-with-show-function/23053/5 "2023-11-07T18:24:18Z")

</div>

I see! One possibility would be to make sure that the tube runs completely just inside the big torus:

```
\[CurlyPhi] = \[Pi] {1/4, 1/2, 3/4};
rTube = .005; (* radius of tube *)
x[t_] := 2 + Cos[t];
z[t_] := Sin[t];
g1 = RevolutionPlot3D[{x[t], z[t]}, {t, 0, 2 \[Pi]}, {\[Phi], 0, 2 \[Pi]}, PlotPoints -> 100, Mesh -> None, Axes -> False];
g2 = ParametricPlot3D[Table[{(2 + (1 - rTube) Cos[t]) Cos[\[CurlyPhi][[i]]], (2 + (1 - rTube) Cos[t]) Sin[\[CurlyPhi][[i]]], (1 - rTube) z[t]}, {i, 3}], {t, 0, 2 \[Pi]}] /. Line[p__] :> Tube[p, rTube];
Show[g2, g1, Boxed -> False, Axes -> False, PlotRange -> All, ViewVector -> {{2.8, 0, 0}, {0, 2.5, 0}}, ViewAngle -> 70 °]

```

Does that help?

---

<div class="post-metadata">

**Author:** ![henrikschachner](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/henrikschachner/32/32119_2.png) [@henrikschachner](https://community.wolfram.com/u/henrikschachner)\
**Post date:** [November 7, 2023, 6:35pm UTC](https://community.wolfram.com/t/3d-graphics-overlaying-with-show-function/23053/6 "2023-11-07T18:35:34Z")

</div>

Hello Hans,

> In Mathematica version 12.3 the rendering is as expected:

yes, at first I thought so too. But it appears not to be robust. E.g. try

```
ParametricPlot3D[..., PlotStyle -> Thickness[.05]]

```

---

<div class="post-metadata">

**Author:** ![yangjh](https://avatars.discourse-cdn.com/v4/letter/y/3e96dc/32.png) [@yangjh](https://community.wolfram.com/u/yangjh)\
**Post date:** [November 8, 2023, 12:50am UTC](https://community.wolfram.com/t/3d-graphics-overlaying-with-show-function/23053/7 "2023-11-08T00:50:27Z")

</div>

Yes, it is. The problem appears to be related with the view direction from inside to outside of the torus. There is no issue when the view direction in the opposite side.
