Labelling Multiple Lines on a Graph
Learn how to add labels to multiple lines.
We'll cover the following
Our previous example of a graph with multiple lines is a thing of rare beauty. But which line relates to which set of data? We have data that defines values for open
and close
, but we don’t know which line is which.
In this section, we will add labels to our lines so that we know which is which.
It’s actually not too difficult. What we are trying to achieve is finding the position of the end of each line and adding a text label at that position so that the association of proximity denotes the linkage. Of course, we’re going to go a little further and color the text so that it’s really clear which label belongs with which line, but you get the idea.
The code
Each line requires a single block of the script to add the text. The block that adds the open
label is as follows:
Get hands-on with 1400+ tech skills courses.