label_pct
label_pct(digits=0, suffix='%')Percent label formatter.
Returns a function that turns numbers on a 0-100 scale into percent strings: 42 becomes “42%”. It returns a function, the form plotnine scales expect for their labels argument. The number is rounded to digits places as C’s printf does and suffix appended.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| digits | int | Decimal places to keep. Default 0. | 0 |
| suffix | str | Text appended after the number. Default “%”. | '%' |
Returns
| Name | Type | Description |
|---|---|---|
| callable | A function from a list of numbers to a list of strings. |
See Also
scale_y_pct
Examples
>>> label_pct()([0, 33.4, 100])
>>> label_pct(1)([33.45])