PeanoCurve[n]
gives the line segments representing the n
-step Peano curve.
PeanoCurve
PeanoCurve[n]
gives the line segments representing the n
-step Peano curve.
Details and Options
- PeanoCurve is also known as Peano space-filling curve.
- PeanoCurve returns a Line primitive corresponding to a path that starts at {0,0}, then joins all integer points in the 3n-1 by 3n-1 square, and ends at {3n-1,3n-1}. »
- PeanoCurve takes a DataRange option that can be used to specify the range the coordinates should be assumed to occupy.
Examples
open all close allBasic Examples (2)
Graphics[PeanoCurve[2]]Lengths of the approximations to the Peano curve:
Table[RegionMeasure[PeanoCurve[n]], {n, 4}]FindSequenceFunction[%, n]Visualize the Peano curve in 2D with splines:
Graphics[{Thickness[Large], PeanoCurve[3] /. Line -> BSplineCurve}]Scope (6)
Curve Specification (2)
Curve Styling (4)
Peano curves with different thicknesses:
Table[Graphics[{Thickness[i], PeanoCurve[3]}], {i, {Medium, Large}}]Table[Graphics[{Thickness[i], PeanoCurve[2]}], {i, {.005, .05, .1}}]Thickness in printer's points:
Table[Graphics[{AbsoluteThickness[i], PeanoCurve[2]}], {i, {1, 5, 10}}]Table[Graphics[{Dashing[i], PeanoCurve[3]}], {i, {Tiny, Small, Medium, Large}}]Table[Graphics[{d, PeanoCurve[3]}], {d, {Dotted, Dashed, DotDashed}}]Table[Graphics[{c, PeanoCurve[3]}], {c, {Red, Green, Blue, Yellow}}]Options (1)
DataRange (1)
DataRange allows you to specify the range of mesh coordinates to generate:
PeanoCurve[1]PeanoCurve[1, DataRange -> {{0, 1}, {0, 1}}]Applications (4)
PeanoCurve is constructed recursively by transforming segments into curves linked together by lines:
scups[curve_] := With[{part = Partition[First[curve], UpTo[10], 9]},
Graphics[Apply[{{Thick, Line[#1]}, {Dashing[{0, 0.02}], Line[#2]}}&, Map[Partition[#, UpTo[9], 8]&, part], {1}]]]Row[{scups[PeanoCurve[1]], scups[PeanoCurve[2]]}, Spacer[40]]color[curve_, n_ : 1] := With[{color = ColorData[97, "ColorList"], data = First[scups[curve]]},
Graphics[MapIndexed[{color[[First[#2]]], #1}&, Partition[data, n]]]]Row[{color[PeanoCurve[2]], color[PeanoCurve[3], 9]}, Spacer[40]]Visualize the Peano curve in 2D:
Graphics[PeanoCurve[2]]% /. Line -> BSplineCurveGraphics[{Orange, Polygon[Join[First@PeanoCurve[4], {{81, 80}, {81, -1}, {0, -1}}]]}]Apply a Peano curve texture to a surface:
ParametricPlot3D[{1.16 ^ v Cos[v](1 + Cos[u]), -1.16 ^ v Sin[v](1 + Cos[u]), -2 1.16 ^ v(1 + Sin[u])}, {u, 0, 2Pi}, {v, -15, 6}, PlotStyle -> Directive[Specularity[White, 30], Texture[Graphics[PeanoCurve[4]]]], TextureCoordinateFunction -> ({#4, 2#5}&), Lighting -> "Neutral", Mesh -> None, PlotRange -> All, Boxed -> False, Axes -> False]Properties & Relations (3)
PeanoCurve consists of lines:
PeanoCurve[1]Find the perimeter of the 2D Peano curve:
Table[Graphics[PeanoCurve[n]], {n, 3}]Table[RegionMeasure[PeanoCurve[n]], {n, 4}]FindSequenceFunction[%, n]DataRange->range is equivalent to using RescalingTransform[{...},range]:
Region[PeanoCurve[2, DataRange -> {{1, 2}, {1, 3}}], Frame -> True]Use RescalingTransform:
box = TransformedRegion[PeanoCurve[2], RescalingTransform[{{0, 3^2 - 1}, {0, 3^2 - 1}}, {{1, 2}, {1, 3}}]];Region[box, Frame -> True]Possible Issues (2)
By default, the coordinates of a Peano curve are not in the unit square:
PeanoCurve[1]Using DataRange to generate a Peano curve in the unit square:
PeanoCurve[1, DataRange -> {{0, 1}, {0, 1}}]PeanoCurve can be too large to generate:
PeanoCurve[20]Related Guides
History
Text
Wolfram Research (2017), PeanoCurve, Wolfram Language function, https://reference.wolfram.com/language/ref/PeanoCurve.html.
CMS
Wolfram Language. 2017. "PeanoCurve." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/PeanoCurve.html.
APA
Wolfram Language. (2017). PeanoCurve. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PeanoCurve.html
BibTeX
@misc{reference.wolfram_2026_peanocurve, author="Wolfram Research", title="{PeanoCurve}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/PeanoCurve.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_peanocurve, organization={Wolfram Research}, title={PeanoCurve}, year={2017}, url={https://reference.wolfram.com/language/ref/PeanoCurve.html}, note=[Accessed: 12-June-2026]}