Skip to content

coord_3d

coord_3d(
    azimuth: Number = -60.0,
    elevation: Number = 30.0,
    perspective: bool = False,
) -> FeatureSpec

Show x, y and z in a static 3D view (ggrust only: lets-plot and ggplot2 have no 3D).

Map z in aes(). geom_point and geom_path draw in 3D; any other geom raises SpecError. Points (and paths, as whole lines) are drawn back to front. The box is 4:4:3 and the default view is matplotlib's. Legends, themes and facets work as in 2D; HTML output has no rotation, tooltips or zoom.

Parameters:

  • azimuth (float, default: -60.0 ) –

    View angle around the z axis, in degrees (matplotlib azim).

  • elevation (float, default: 30.0 ) –

    View angle above the x-y plane, in degrees (matplotlib elev).

  • perspective (bool, default: False ) –

    Perspective projection (the far side looks smaller) instead of orthographic.

Returns:

  • FeatureSpec –

    The coordinate system.

Raises:

  • SpecError –

    If azimuth or elevation is not a finite number.

Examples:

>>> from ggrust import *
>>> data = {
...     "length": [5.1, 4.9, 6.4, 6.9, 6.3, 5.8],
...     "width": [3.5, 3.0, 3.2, 3.1, 3.3, 2.7],
...     "petal": [1.4, 1.4, 4.5, 4.9, 6.0, 5.1],
...     "species": ["A", "A", "B", "B", "C", "C"],
... }
>>> plot = ggplot(data, aes("length", "width", z="petal", color="species")) + geom_point()
>>> plot = plot + coord_3d(azimuth=-50, elevation=20)

Another view angle, with perspective:

>>> plot = ggplot(data, aes("length", "width", z="petal", color="species"))
>>> plot = plot + geom_point(size=4) + coord_3d(azimuth=30, elevation=15, perspective=True)

Another view angle, with perspective