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 recieve 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 and Use Bar Charts in R
The chart type seems simple enough, but there sure are a lot of bad ones out there. Get yourself out of default mode.
Choropleth Maps and Shapefiles in R
Fill those empty polygons with color, based on shapefile or external data.
How to Make Animated (GIF) Heatmaps in R
Using color as the visual encoding, show changes over time in two dimensions.