Skip to content

Commit 4336c3b

Browse files
committed
Document unit semantics in the margin class docstring
1 parent 9f75fa8 commit 4336c3b

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

plotnine/themes/elements/margin.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,30 @@
1919
@dataclass
2020
class margin:
2121
"""
22-
Margin
22+
Margin around a themeable
23+
24+
Holds four edge values (top, right, bottom, left) in one of
25+
several coordinate spaces selected by the `unit` attribute.
26+
27+
Notes
28+
-----
29+
Supported units:
30+
31+
- `"pt"`: typographic points (1/72 in).
32+
- `"in"`: inches.
33+
- `"lines"`: multiples of the element's font size, applied
34+
uniformly to all four edges. One line equals `fontsize/72`
35+
inches of space on every edge — roughly a CSS em horizontally
36+
and fontsize-tall vertically, not a line-height-with-leading
37+
as the name may suggest.
38+
- `"fig"`: figure-fraction, interpreted per edge: top and bottom
39+
as a fraction of figure height, left and right as a fraction
40+
of figure width.
41+
42+
For `pt`, `in`, and `lines`, equal edge values produce equal
43+
physical distances regardless of figure aspect ratio. For `fig`,
44+
top/bottom and left/right are fractions of different dimensions
45+
by design.
2346
"""
2447

2548
t: float = 0
@@ -44,7 +67,8 @@ class margin:
4467

4568
unit: Literal["pt", "in", "lines", "fig"] = "pt"
4669
"""
47-
The units (coordinate space) of the values
70+
Coordinate space of the edge values. See the class docstring
71+
for the meaning of each option.
4872
"""
4973

5074
# These are set by the themeable when it is applied

0 commit comments

Comments
 (0)