Tube
Details and Options
- Tube renders as a circular 3D tube in Graphics3D.
- The radius of the tube can be specified either in absolute coordinates, or as Scaled[s].
- If no explicit radius is specified, Tube uses a small scaled radius.
- Tube[{pt1,pt2,…},{r1,r2,…}] specifies a different tube radius at the position of each of the points pti.
- Tube[{pt1,pt2,…},…] gives a tube consisting of a sequence of straight segments. It is equivalent to Tube[Line[{pt1,…}],…].
- The following curve specifications can be used:
-
Line[…] piecewise line segments BezierCurve[…] composite Bezier curve BSplineCurve[…] B-spline curve - By default, the joins between tube segments are rounded.
- Different forms of joining between tube segments can be specified using JoinForm.
- By default, the ends of the tube are rounded.
- Different caps for the tube can be specified using CapForm.
- CapForm[None] specifies that the end of the tube should be left open.
- In Tube[curve,…], curve can have head BezierCurve, BSplineCurve, or Line.
- Colors and other material properties of tubes can be specified using color directives as well as Specularity and Glow.
- Tubes can be specified as transparent using Opacity directives.
- Individual coordinates and lists of coordinates in tubes can be Dynamic objects.
Examples
open all close allBasic Examples (4)
Graphics3D[Tube[{{0, 0, 0}, {1, 1, 1}}]]Graphics3D[Tube[BSplineCurve[{{1, 1, -1}, {2, 2, 1}, {3, 3, -1}, {3, 4, 1}}]]]Graphics3D[Tube[{{0, 0, 0}, {1, 1, 1}}, .1]]t = Tube[{{-1, -1, -1}, {0, 0, 1}, {1, 1, -1}}, 0.4];{Graphics3D[{Red, t}], Graphics3D[{CapForm["Round"], t}], Graphics3D[{JoinForm["Miter"], t}]}Scope (16)
Tube Specification (7)
Graphics3D[Tube[{{0, 0, 0}, {2, 1, 1}}]]Multiple connected tube segments:
Graphics3D[Tube[{{0, 0, 0}, {2, 1, 1}, {4, 0, 0}}]]Multiple disconnected tube segments:
s = {{0, 0, 0}, {2, 1, 1}, {4, 0, 0}};{Graphics3D[Tube[{s, s + 1}]], Graphics3D[Tube[BSplineCurve[{s, s + 1}]]]}s = {{-1, -1, -1}, {1, 1, 1}};Table[Graphics3D[Tube[s, i]], {i, {.05, .1, .2}}]Radii can also be specified at vertices:
{Graphics3D[{CapForm[None], Tube[{{0, 0, 0}, {1, 1, 1}}, {1, 2}]}], Graphics3D[{CapForm["Round"], Tube[{{0, 0, 0}, {-6, 4, 10}}, {2, 1}]}]}s = {{-1, -1, -1}, {1, 1, 1}};Table[Graphics3D[Tube[s, Scaled[i]], PlotRange -> 1.5], {i, {.01, .02, .04}}]Tube can take a line or curve argument:
{Graphics3D[Tube[Line[{{0, 0, 0}, {1, 1, 0}, {2, 0, 0}}], .1]], Graphics3D[{Tube[BezierCurve[{{0, 0, 0}, {1, 1, 0}, {2, 0, 0}}], .1]}]}Tube Styling (8)
l = Tube[{{1, 1, -1}, {2, 2, 1}, {3, 3, -1}, {4, 4, 1}}, 0.1];Table[Graphics3D[{c, CapForm[None], JoinForm[None], l}], {c, {Red, Green, Blue, Yellow}}]Different properties can be specified for the front and back faces using FaceForm:
Graphics3D[{FaceForm[Yellow, Blue], Tube[{{0, 0, -1}, {0, 0, 1}}, 1]}, PlotRange -> {{-1, 1}, {-.8, 1}, {-1, 1}}]Tubes with different specular exponents:
Table[Graphics3D[{Orange, Specularity[GrayLevel[1], n], CapForm["Round"], Tube[{{0, 0, -1}, {0, 0, 1}}, 1]}, Lighting -> {{"Point", White, Scaled[{2, -1, 1.2}]}}], {n, {5, 20, 100}}]Graphics3D[{Glow[Red], Black, CapForm["Round"], Tube[{{0, 0, -1}, {0, 0, 1}}, 1]}]Opacity specifies the face opacity:
Table[Graphics3D[{CapForm["Round"], Opacity[o], Tube[{{0, 0, -1}, {0, 0, 1}}, 1]}, PlotLabel -> o], {o, {0.3, 0.5, 0.9}}]Tube caps can be specified using CapForm:
Table[Graphics3D[{CapForm[cap], Tube[{{-1, 1, -1}, {1, -1 / 2, 1}}, 0.7]}, PlotRange -> 2, PlotLabel -> Row[{cap}], Boxed -> False], {cap, {None, "Butt", "Round", "Square"}}]Joining of tube segments can be specified using JoinForm:
Table[Graphics3D[{JoinForm[j], Tube[{{-1, -1, -1}, {0, 0, 1}, {1, 1, -1}}, 0.4]}, PlotRange -> 2, PlotLabel -> Row[{j}], Boxed -> False], {j, {None, "Bevel", "Round", "Miter"}}]Colors can be specified at vertices using VertexColors:
Graphics3D[{Tube[{{0, 0, 0}, {2, 1, 1}}, 0.1, VertexColors -> {Red, Green}]}]Coordinate Specification (1)
Use Scaled coordinates:
Graphics3D[Tube[{Scaled[{0, .2, 0}], Scaled[{1, .8, 1}]}], Axes -> True]Options (1)
VertexColors (1)
Use VertexColors to vary the colors along the tube:
Graphics3D[{Tube[{{0, 0, 0}, {2, 1, 1}}, 0.1, VertexColors -> {Red, Green}]}]Applications (4)
PieChart3D uses Tube to produce donut charts:
PieChart3D[{1, 2, 3, 4}, ChartElementFunction -> "TorusSector3D", SectorOrigin -> {Automatic, 1}, BoxRatios -> Automatic]Plot a parametric space curve and replace the curve with a tube:
ParametricPlot3D[{Sin[u], Cos[u], u / 10}, {u, 0, 20}, PlotStyle -> Orange, PlotRange -> All] /. Line[pts_, rest___] :> Tube[pts, 0.1, rest]Tube can be used with Arrow for full 3D arrows:
Graphics3D[{Arrowheads[.4], Blue, Arrow[Tube[{{0, 0, 0}, {2, 1, 1}}, 0.1, VertexColors -> {Red, Blue}]]}]randomWalk = Accumulate[RandomChoice[Join[IdentityMatrix[3], -IdentityMatrix[3]], 40]];Graphics3D[{Red, CapForm[None], JoinForm[None], Arrowheads[RandomChoice[{{0.04}}, 50]], Arrow[Tube[randomWalk]]}]Use Tube for 3D edges in GraphPlot3D:
GraphPlot3D[{1 -> 2, 2 -> 3, 3 -> 4, 4 -> 1, 4 -> 5, 5 -> 1, 2 -> 5, 3 -> 5}, EdgeShapeFunction -> (Tube[#1, .05]&), VertexShapeFunction -> ({ColorData["Atoms"][RandomInteger[{1, 117}]], Sphere[#1, .15]}&), PlotStyle -> Directive[Specularity[White, 20]]]Obtain directed edges using Arrow:
GraphPlot3D[{1 -> 2, 2 -> 3, 3 -> 4, 4 -> 1, 4 -> 5, 5 -> 1, 2 -> 5, 3 -> 5}, EdgeShapeFunction -> (Arrow@Tube[#1, .03]&), VertexShapeFunction -> ({ColorData["Atoms"][RandomInteger[{1, 117}]], Sphere[#1, .15]}&), PlotStyle -> Directive[Specularity[White, 20], Arrowheads[{{0.1, 0.7}}]]]Properties & Relations (6)
Use Scale to get an elliptical tube:
Graphics3D[Scale[Tube[{{0, 0, -1}, {0, 0, 1}}, 1], {2, 4, 3}, {0, 0, 0}], Axes -> True]Use Arrow with Tube to get a full 3D arrow:
Graphics3D[{Arrowheads[.1], Arrow[Tube[{{0, 0, 0}, {2, 1, 1}}, 0.02]]}]Cone is a special case of Tube:
{Graphics3D[Cone[{{0, 0, 0}, {1, 1, 1}}, 1]], Graphics3D[{CapForm["Butt"], Tube[{{0, 0, 0}, {1, 1, 1}}, {1, 0}]}]}Get a truncated cone by specifying different radii in Tube:
Graphics3D[{CapForm["Butt"], Tube[{{0, 0, 0}, {1, 1, 1}}, {1, 1 / 2}]}]Cylinder is a special case of Tube:
{Graphics3D[Cylinder[{{0, 0, 0}, {1, 1, 1}}, 1]], Graphics3D[{CapForm["Butt"], Tube[{{0, 0, 0}, {1, 1, 1}}, {1, 1}]}]}Get curved cylinder by using additional points:
Graphics3D[{CapForm["Butt"], Tube[{{0, 0, 0}, {1, 1, 1}, {1, 1, 3}}, {1, 1, 1}]}]A parametric specification of a tube generated using ParametricPlot3D:
ParametricPlot3D[{Cos[θ], Sin[θ], z}, {θ, 0, 2 π}, {z, -1, 1}, Mesh -> None]An implicit specification of a tube generated by ContourPlot3D:
ContourPlot3D[x ^ 2 + y ^ 2 == 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, Mesh -> None]Possible Issues (1)
Tube objects can only use machine-number coordinates:
Graphics3D[Tube[{{0, 0, 0}, {10. ^ 500, 10. ^ 500, 10. ^ 500}}]]MachineNumberQ[10. ^ 500]Neat Examples (4)
A random collection of tube curves:
Graphics3D[Tube[BSplineCurve[RandomReal[.1, {20, 3, 3}]]]]Tubes with interpolated colors:
ParametricPlot3D[{Cos[2 t], Sin[2 t], Cos[t]}, {t, 0, 2 Pi}, PlotStyle -> Directive[Opacity[0.7], CapForm[None], JoinForm["Miter"], Red], PlotRange -> All, ColorFunction -> Hue, Boxed -> False, MaxRecursion -> 0, PlotPoints -> 100, Axes -> None, Method -> {"TubePoints" -> 30}] /. Line[pts_, rest___] :> Tube[pts, 0.2, rest]Tube curves with interpolated radii:
Graphics3D[{Red, CapForm["Round"], Tube[BSplineCurve[{{0, 0, 0}, {1, 1, 0}, {1.2, 2, 0}, {.6, 1.8, 0}, {0, 1.3, 0}, {-.6, 1.8, 0}, {-1.2, 2, 0}, {-1, 1, 0}, {0, 0, 0}}], {.1, .1, .1, .1, .3, .1, .1, .1, .1}]}]Graphics3D[{CapForm[None], Tube[BSplineCurve[{{0, 0, -1}, {0, 0, -.5}, {0, 0, 0}, {0, 0, 1}, {0, 0, 15}, {0, 0, 20}, {0, 0, 25}, {0, 0, 32}, {0, 0, 35}}], {6, 6.5, 6, 3.2, 12, 4, 2, 2.4, 3.5}]}]pts = N[Table[10{u, 5 Cos[u u], 5 Sin[u u]}, {u, 1, 10, .3}]];Graphics3D[{Red, Tube[BSplineCurve[pts, SplineDegree -> 3], 5RandomReal[1, 34]], Green, Tube[BSplineCurve[pts, SplineDegree -> 8], 5RandomReal[1, 34]]}, PlotRange -> All]See Also
Cylinder Line BezierCurve BSplineCurve Cone Arrow
Function Repository: DashedTube Graphics3DWireFrame
Related Guides
Text
Wolfram Research (2008), Tube, Wolfram Language function, https://reference.wolfram.com/language/ref/Tube.html (updated 2010).
CMS
Wolfram Language. 2008. "Tube." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2010. https://reference.wolfram.com/language/ref/Tube.html.
APA
Wolfram Language. (2008). Tube. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Tube.html
BibTeX
@misc{reference.wolfram_2026_tube, author="Wolfram Research", title="{Tube}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/Tube.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_tube, organization={Wolfram Research}, title={Tube}, year={2010}, url={https://reference.wolfram.com/language/ref/Tube.html}, note=[Accessed: 12-June-2026]}