Scale ggplot2 Color Gradient to Range Outside of Data in R
In this article, we are going to see how to Scale ggplot2 Color Gradient to Range Outside of Data in R Programming Language.
Under this, we are simply creating a data frame of 6 rows and 3 columns.
Create a graphic of the data
We are using the ggplot function from the ggploe2 library to plot the graph of the given dataframe. Here, we are just visualizing the data frame accordingly in the R programming language.
Specify Colors, Limits & Breaks Using scale_fill_gradient() Function:
In this method, the starting and the ending value of the colors to define a range is given as an argument.
Syntax: scale_fill_gradient(low, high, guide)
- low: starting value
- high: ending value
- guide: type of legend
In this example, we are using the scale_fill_gradient() function to scale ggplot2 Color Gradient to Range Outside of Data bypassing the required parameter to the function in R programming language,