scale_manual ¶
scale_manual(
aesthetic: str | Sequence[str],
values: Sequence[Any] | dict[Any, Any],
*,
name: str | None = None,
breaks: Breaks | None = None,
labels: Labels | None = None,
lablim: int | None = None,
limits: Limits | None = None,
na_value: Color | Number | None = None,
guide: Guide | None = None,
format: str | None = None,
) -> FeatureSpec
Your own values for any aesthetic, or for several at once.
Parameters:
-
aesthetic(str or list of str) –The aesthetic(s) the scale maps, e.g.
"color"or["color", "fill"]. A list gives each aesthetic the same scale. -
values(list or dict) –Values matched in order with the scale's categories, or a dict from category to value.
-
name(str, default:None) –Legend title.
-
breaks(list or dict, default:None) –Categories that get a legend key (a dict maps labels to breaks).
-
labels(list of str or dict, default:None) –One label per break (a dict maps breaks to labels).
-
lablim(int, default:None) –Maximum label length in characters; longer labels are cut.
-
limits(list, default:None) –The categories (and their order). Data outside the limits gets
na_value. -
na_value(optional, default:None) –Value drawn for missing data and data outside
limits. -
guide(str or FeatureSpec, default:None) –"legend","none", or aguide_legend()spec. -
format(str, default:None) –Label format, e.g.
".1f".labelstake precedence.
Returns:
-
FeatureSpec–The scale, or a
FeatureSpecArrayof one scale per aesthetic for a list.
Raises:
-
UnsupportedValueError–If
aestheticis not a string or a list of strings. -
SpecError–If
aestheticis an empty list.
Examples:
>>> from ggrust import *
>>> data = {"age": [1, 3, 5, 7, 2, 4, 6, 8, 3, 9],
... "weight": [4, 6, 6, 7, 8, 12, 14, 15, 2, 3],
... "pet": ["cat"] * 4 + ["dog"] * 4 + ["rabbit"] * 2}
>>> plot = ggplot(data, aes("age", "weight", color="pet", fill="pet"))
>>> plot = plot + geom_point(shape=21, size=6, alpha=0.5)
>>> plot = plot + scale_manual(
... ["color", "fill"], values=["darkorange", "saddlebrown", "grey"]
... )