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 Polar Density Plot in R
With cyclical data, a circular format might be useful. Combine that with a smooth density to reduce noise, and you got yourself a plot.
How to Make Line Charts in Python, with Pandas and Matplotlib
The chart type can be used to show patterns over time and relationships between variables. This is a comprehensive introduction to making them using two common libraries.
How to visualize data with cartoonish faces ala Chernoff
The goal of Chernoff faces is to show a bunch of variables at once via facial features like lips, eyes, and nose size. Most of the time there are better solutions, but the faces can be interesting to work with.