Data Visualization, Data Storytelling
Simplify your overwhelmed charts by using slope charts: a tutorial in Python Altair
We may plot charts to include as many concepts as possible in our visualization. As a result, our chart could be difficult to read and distracting. For this reason, before plotting anything, sit in your chair and plan what you want to communicate. Then, look at your data and decide what is effectively necessary to plot. Leave the rest out of your visualization.
In this tutorial, we’ll see how to use slope charts to simplify an overwhelming trendline. If you are a data analyst, you might jump out of your chair and get scared because, using a slope chart, you will see a significant loss of information. But I assure you that, in some cases, it will really be worth it.
Let’s see the cases where a slope chart can be used.
A slope chart is a type of line chart showing only the first and last points, as shown in the following figure.
A slope chart is particularly useful when you want to know only the slope of your data trend. Thus, slope charts are useful to simplify trendlines. For example, you could use a slope chart to see if product sales increase or decrease over a period. Imagine that you have many trend lines to represent in the same chart, and you are interested only in each trend line’s first and last values. You can simplify the chart by using a slope chart.
Let’s implement a practical example to see how to implement a slope chart in Python Altair, a Python library for data visualization.
Consider the arrivals at tourist accommodation establishments dataset, released as open data by Eurostat. Imagine you want to compare the tourist arrivals in Portugal with those in the other five countries: Germany, France, Italy, the…