How to Make a Line Chart with a Color Gradient in R
Use color to reinforce or add another layer of meaning to a regular line chart.
It’s typically straightforward to make and read a line chart. The position on the line represents a value, and the slope between points represents a rate of change.
Usually a line chart that represents a single time series uses a solid color for the line. But while messing with a heatmap, which uses color as its primary visual encoding, I was curious what you could show if you introduced a color scheme to a line chart.
A diverging color scale indicates whether births were above or below the baseline. While the line itself shows the same change, the color seems to highlight the changes.
In this tutorial, you’ll learn how to make a similar gradient line.
To access this full tutorial, you must be a member. (If you are already a member, log in here.)
You will get unlimited access to step-by-step visualization courses and tutorials for insight and presentation — all while supporting an independent site. Files and data are included so that you can more easily apply what you learn in your own work.
Learn to make great charts that are beautiful and useful.
Members also receive a weekly newsletter, The Process. Keep up-to-date on visualization tools, the rules, and the guidelines and how they all work together in practice.
See samples of everything you gain access to:
More Tutorials See All →
How to Make a Spiral Chart in R
Using a spiral might not be the best way to encode data. But here’s how to do it anyway. Just in case.
How to Make Frequency Trails in Excel
Also known as ridgelines, use the method to create a compact visualization where you can easily identify major patterns and outliers.