new_scale ¶
new_scale(new_aes: str) -> FeatureSpec
Start a new scale for an aesthetic (R package ggnewscale).
Layers, scales, guides() and labs() added with + after it use a new,
separate scale for new_aes with its own legend; those added before keep the
earlier one. Add it again to start a third scale, and so on.
Parameters:
-
new_aes(str) –The style aesthetic:
"color"(or"colour"),"fill","size","alpha","shape","linetype". Position aesthetics are not accepted.
Returns:
-
FeatureSpec–The marker, to add to a plot with
+.
Raises:
-
SpecError–When
new_aesis not a style aesthetic.
Examples:
>>> from ggrust import *
>>> data = {"x": [1, 2, 3, 4], "y": [2, 4, 3, 5], "size": [1, 3, 2, 4]}
>>> plot = ggplot(data, aes("x", "y")) + geom_point(aes(size="size"))
>>> plot = plot + new_scale("size") + geom_point(aes(size="y"), color="red", alpha=0.4)