Skip to content

Commit cf8eb8f

Browse files
iangowhas2k1
authored andcommitted
Document guide_axis_theta semantics
1 parent d62df76 commit cf8eb8f

1 file changed

Lines changed: 80 additions & 8 deletions

File tree

plotnine/guides/guide_axis_theta.py

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,78 @@ class guide_axis_theta:
1010
"""
1111
Theta-axis guide for radial coordinates.
1212
13-
This guide is consumed by ``coord_radial`` when it draws theta-axis
14-
tick labels. It is not drawn as a legend or colorbar.
13+
A specialized guide used in :class:`~plotnine.coords.coord_radial` to
14+
control how tick labels are rendered on the theta (angular) axis.
15+
Unlike legend-style guides, this guide is not drawn as a box or colorbar;
16+
it is consumed directly by ``coord_radial`` when it positions and rotates
17+
the outer tick labels.
18+
19+
Parameters
20+
----------
21+
title :
22+
Title for the guide. Currently unused; theta-axis labels do not
23+
display a title in Matplotlib's polar axes.
24+
theme :
25+
A :class:`~plotnine.themes.theme.theme` object to style the guide
26+
individually. Currently unused.
27+
angle :
28+
Orientation of the tick labels, in degrees, measured as an offset
29+
from the **tangential direction** at each tick position.
30+
31+
* ``None`` (default) - labels are not rotated by this guide; the
32+
Matplotlib default (horizontal, i.e. ``0`` absolute) is used.
33+
* ``0`` - labels are oriented tangentially, parallel to the arc.
34+
This matches the ggplot2 heuristic default and is the most common
35+
choice.
36+
* ``90`` - labels point radially outward along the spoke.
37+
* Any other float - a corresponding offset from the tangential
38+
direction.
39+
40+
.. note::
41+
This differs from Matplotlib's ``tick_params(labelrotation=N)``,
42+
which treats ``N`` as an **absolute** angle. Here ``angle`` is
43+
always relative to the tangent at each label's position.
44+
45+
minor_ticks :
46+
Whether to draw minor ticks. Not yet implemented; the value is
47+
stored but has no effect.
48+
cap :
49+
Whether to cap the axis line back to the outermost breaks. Not
50+
yet implemented; the value is stored but has no effect.
51+
order :
52+
Order of this guide among multiple guides. Not yet implemented.
53+
position :
54+
Guide position (``"top"``, ``"bottom"``, ``"left"``, or
55+
``"right"``). Not yet implemented.
56+
57+
See Also
58+
--------
59+
:class:`~plotnine.coords.coord_radial` : The coordinate system that
60+
consumes this guide.
61+
plotnine.guides : Add guides to a plot with ``guides(theta=...)``.
62+
63+
Examples
64+
--------
65+
Make theta labels follow the arc (tangential, matching ggplot2's default
66+
heuristic):
67+
68+
.. code-block:: python
69+
70+
from plotnine import ggplot, aes, geom_point, coord_radial, guides
71+
from plotnine.guides import guide_axis_theta
72+
from plotnine.data import mtcars
73+
74+
(
75+
ggplot(mtcars, aes("disp", "mpg"))
76+
+ geom_point()
77+
+ coord_radial(theta_labels=True)
78+
+ guides(theta=guide_axis_theta(angle=0))
79+
)
80+
81+
.. note::
82+
``coord_radial`` hides theta labels on full-circle plots by default
83+
(``theta_labels=False``). You must pass ``theta_labels=True`` to
84+
``coord_radial`` for this guide to have any visible effect.
1585
"""
1686

1787
title: str | None = None
@@ -22,19 +92,21 @@ class guide_axis_theta:
2292

2393
angle: float | None = None
2494
"""
25-
Angle in degrees at which to draw theta-axis tick labels.
95+
Offset from the tangential direction in degrees.
2696
27-
If ``None``, Matplotlib's default theta tick label rotation is used.
97+
``None`` keeps Matplotlib's default (horizontal labels).
98+
``0`` makes labels tangential (parallel to the arc).
99+
``90`` makes labels radial (pointing outward).
28100
"""
29101

30102
minor_ticks: bool | None = None
31-
"""Whether to draw minor ticks. Currently unused."""
103+
"""Whether to draw minor ticks. Not yet implemented."""
32104

33105
cap: bool | None = None
34-
"""Whether to cap the axis line. Currently unused."""
106+
"""Whether to cap the axis line. Not yet implemented."""
35107

36108
order: int = 0
37-
"""Order of this guide among multiple guides. Currently unused."""
109+
"""Order of this guide among multiple guides. Not yet implemented."""
38110

39111
position: str | None = None
40-
"""Guide position. Currently unused."""
112+
"""Guide position. Not yet implemented."""

0 commit comments

Comments
 (0)