

By default, the colours are presumed to be equally spaced along the scale, but if you prefer you can specify a vector of values that correspond to each of the reference colours. The third method is to use scale_fill_gradientn() which takes a vector of reference colours as its argument, and constructs a scale that linearly interpolates between the specified values. Note that the mid argument specifies the colour to be shown at the intermediate point, and midpoint is the value in the data at which this colour is used (the default is midpoint = 0). The second plot has the same endpoints but uses scale_fill_gradient2() to interpolate first from grey to white ( #ffffff) and then from white to brown. The first plot uses a scale that linearly interpolates from grey (hex code: "#bebebe") at the low end of the scale limits to brown ( "#a52a2a") at the high end. The use of gradient scales is illustrated below. scale_fill_gradientn() produces an n-colour gradient.scale_fill_gradient2() produces a three-colour gradient with specified midpoint.

#GGPLOT2 SCATTER PLOT CONTINUOUS PALETTE SERIES#
2.6.5 Time series with line and path plots.2.6.3 Histograms and frequency polygons.2.4 Colour, size, shape and other aesthetic attributes.1.3 How does ggplot2 fit in with other R graphics?.ggplot2: elegant graphics for data analysis.
