Most of the time I use diverging colors in plotting bias values around a 0 midpoint, and indeed ggplot2 uses 0 as the default midpoint. A consequence is that if all your data values on the color aesthetic are positive and if you don't pass a midpoint (default 0) you will merely get a 2-color smooth gradient. This is a smart default: when using a diverging color gradient (scale_color_gradient2) the value from which the colors diverge (i.e. which value means "no effect") is the most important semantic aspect of the color ramp.
Possibly related: I notice Python's ggplot documentation says that scale_color_gradient2 takes a limits argument, but I don't see it make any difference in my plots. I might guess that limits was intended to allow the library to infer the midpoint, but (1) it doesn't do that, and anyway (2) I don't see this being practical for the user; the desired midpoint is rarely the mean or median of my data range.
Function
scale_color_gradient2
should take the data value to which the colormid
should be set. In ggplot2 you pass this value asmidpoint
:Most of the time I use diverging colors in plotting bias values around a 0 midpoint, and indeed ggplot2 uses 0 as the default midpoint. A consequence is that if all your data values on the color aesthetic are positive and if you don't pass a midpoint (default 0) you will merely get a 2-color smooth gradient. This is a smart default: when using a diverging color gradient (scale_color_gradient2) the value from which the colors diverge (i.e. which value means "no effect") is the most important semantic aspect of the color ramp.
Possibly related: I notice Python's ggplot documentation says that
scale_color_gradient2
takes alimits
argument, but I don't see it make any difference in my plots. I might guess thatlimits
was intended to allow the library to infer themidpoint,
but (1) it doesn't do that, and anyway (2) I don't see this being practical for the user; the desired midpoint is rarely the mean or median of my data range.