This post explains how to build a line chart in base R, where the line color is set according to the Y axis value. Reproducible code is provided.
The plotrix
library allows to change the line color
according to the value of the Y axis thanks to the
clplot
function.
Here, the RColorBrewer
package is used to set a palette
of 8 colors.
Note:: Thanks to Carl Witthoft for sending this chart.
👋 After crafting hundreds of R charts over 12 years, I've distilled my top 10 tips and tricks. Receive them via email! One insight per day for the next 10 days! 🔥