Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

Changing the Color

00:00 Changing the color. Many of the customers of the café like to read the labels carefully, especially to find out the sugar content of the drinks they’re buying.

00:10 The café owner wants to emphasize his selection of healthy foods in his next marketing campaign, so he categorizes the drinks based on their sugar content and uses a traffic light system to indicate low, medium, or high sugar content for the drinks.

00:26 You can add color to the markers in the scatter plot to show the sugar content of each drink. Here, you define the variables low, medium, and high to be tuples, each containing three values that represent the red, green, and blue color components, in that order.

00:45 These are RGB color values. The tuples for low, medium, and high represent green, yellow, and red, respectively.

00:56 Next, the variable sugar_content was defined to classify each drink.

01:12 You use the optional parameter c in the function call to define the color of each marker.

01:21 Onscreen, you can now see the scatter plot produced by this code. The café owner has already decided to remove the most expensive drink from the menu as this doesn’t sell well and has a high sugar content.

01:34 Should he also stop stocking the cheapest of the drinks to boost the health credentials of the business, even though it sells well and has a good profit margin?

01:43 That’s a question for him to answer now that he knows what the data points to. In the next section of the course, you’ll see how to change the shape of markers, once more increasing the information density on a single plot.

Become a Member to join the conversation.