Changing the Size
00:00 Changing the size. Let’s return to the café owner you met earlier on. The different orange drinks he sells come from different suppliers and have different profit margins.
00:12 You can show this additional information in the scatter plot by adjusting the size of the marker. The profit margin is given as a percentage in this example.
01:14 You may have noticed a few changes from the first example. Instead of lists, you’re now using NumPy arrays. You can use any array-like data structure for the data, and NumPy arrays are commonly used in this kind of application because they enable element-wise operations that are performed efficiently.
01:32
The NumPy module is a dependency of Matplotlib, which is why you didn’t need to install it manually. You’ve also used named parameters as input arguments in the function call. The parameters x
and y
are required but all the other parameters are optional.
01:48
The parameter s
denotes the size of the marker. In this example, you use the profit margin as a variable to determine the size of the marker and multiply it by 10
to display the size difference more clearly.
02:02 Onscreen, you can see the scatter plot created by this code. The size of the marker indicates the profit margin for each product. The two orange drinks that sell the most are also the ones that have the highest profit margin. This is good news for the café owner.
02:20 In the next section of the course, you’ll see how to change the color of markers and include more information on the same scatter plot.
Become a Member to join the conversation.