@@ -42,12 +42,6 @@ class geom_text(geom):
42
42
parse : bool, default=False
43
43
If `True`{.py}, the labels will be rendered with
44
44
[latex](http://matplotlib.org/users/usetex.html).
45
- family : str, default=None
46
- Font family.
47
- fontweight : int | str, default="normal"
48
- Font weight.
49
- fontstyle : Literal["normal", "italic", "oblique"], default="normal"
50
- Font style.
51
45
nudge_x : float, default=0
52
46
Horizontal adjustment to apply to the text
53
47
nudge_y : float, default=0
@@ -87,13 +81,64 @@ class geom_text(geom):
87
81
88
82
**Aesthetics Descriptions**
89
83
84
+ `size`
85
+
86
+ : Float or one of:
87
+
88
+ ```python
89
+ {
90
+ "xx-small", "x-small", "small", "medium", "large",
91
+ "x-large", "xx-large"
92
+ }
93
+ ```
94
+
90
95
`ha`
91
96
92
- : Horizontal alignment. One of * left*, * center* or * right.*
97
+ : Horizontal alignment. One of `{" left", " center", " right"}`{.py}.
93
98
94
99
`va`
95
100
96
- : Vertical alignment. One of *top*, *center*, *bottom*, *baseline*.
101
+ : Vertical alignment. One of
102
+ `{"top", "center", "bottom", "baseline", "center_baseline"}`{.py}.
103
+
104
+ `family`
105
+
106
+ : Font family. Can be a font name
107
+ e.g. "Arial", "Helvetica", "Times", ... or a family that is one of
108
+ `{"serif", "sans-serif", "cursive", "fantasy", "monospace"}}`{.py}
109
+
110
+ `fontweight`
111
+
112
+ : Font weight. A numeric value in range 0-1000 or a string that is
113
+ one of:
114
+
115
+ ```python
116
+ {
117
+ "ultralight", "light", "normal", "regular", "book", "medium",
118
+ "roman", "semibold", "demibold", "demi", "bold", "heavy",
119
+ "extra bold", "black"
120
+ }
121
+ ```
122
+
123
+ `fontstyle`
124
+
125
+ : Font style. One of `{"normal", "italic", "oblique"}`{.py}.
126
+
127
+ `fontvariant`
128
+
129
+ : Font variant. One of `{"normal", "small-caps"}`{.py}.
130
+
131
+ `fontstretch`
132
+
133
+ : Font Stretch. A numeric value in range 0-1000, or one of:
134
+
135
+ ```python
136
+ {
137
+ "ultra-condensed", "extra-condensed", "condensed",
138
+ "semi-condensed", "normal", "semi-expanded", "expanded",
139
+ "extra-expanded", "ultra-expanded"
140
+ }
141
+ ```
97
142
"""
98
143
DEFAULT_AES = {
99
144
"alpha" : 1 ,
@@ -103,16 +148,18 @@ class geom_text(geom):
103
148
"lineheight" : 1.2 ,
104
149
"ha" : "center" ,
105
150
"va" : "center" ,
151
+ "family" : None ,
152
+ "fontweight" : "normal" ,
153
+ "fontstyle" : "normal" ,
154
+ "fontvariant" : None ,
155
+ "fontstretch" : None ,
106
156
}
107
157
REQUIRED_AES = {"label" , "x" , "y" }
108
158
DEFAULT_PARAMS = {
109
159
"stat" : "identity" ,
110
160
"position" : "identity" ,
111
161
"na_rm" : False ,
112
162
"parse" : False ,
113
- "family" : None ,
114
- "fontweight" : "normal" ,
115
- "fontstyle" : "normal" ,
116
163
"nudge_x" : 0 ,
117
164
"nudge_y" : 0 ,
118
165
"adjust_text" : None ,
@@ -198,14 +245,18 @@ def draw_group(
198
245
199
246
# Create a dataframe for the plotting data required
200
247
# by ax.text
201
- plot_data = data [["x" , "y" , "size" , "ha" , "va" ]].copy ()
202
- plot_data ["s" ] = data ["label" ]
203
- plot_data ["rotation" ] = data ["angle" ]
204
- plot_data ["linespacing" ] = data ["lineheight" ]
248
+ ae_names = list (set (geom_text .DEFAULT_AES ) | geom_text .REQUIRED_AES )
249
+ plot_data = data [ae_names ]
250
+ plot_data .rename (
251
+ {
252
+ "label" : "s" ,
253
+ "angle" : "rotation" ,
254
+ "lineheight" : "linespacing" ,
255
+ },
256
+ axis = 1 ,
257
+ inplace = True ,
258
+ )
205
259
plot_data ["color" ] = color
206
- plot_data ["family" ] = params ["family" ]
207
- plot_data ["fontweight" ] = params ["fontweight" ]
208
- plot_data ["fontstyle" ] = params ["fontstyle" ]
209
260
plot_data ["zorder" ] = params ["zorder" ]
210
261
plot_data ["rasterized" ] = params ["raster" ]
211
262
plot_data ["clip_on" ] = True
@@ -299,7 +350,7 @@ def draw_legend(
299
350
y = 0.5 * da .height ,
300
351
text = "a" ,
301
352
size = data ["size" ],
302
- family = lyr . geom . params ["family" ],
353
+ family = data ["family" ],
303
354
color = color ,
304
355
rotation = data ["angle" ],
305
356
horizontalalignment = "center" ,
0 commit comments