Change them all!

Report a typo

You need to change the color and thickness of all lines of your box plot, including the box, whiskers, median, and caps.

How would you finish the 13th line of code below to get the pictured result?

import matplotlib.pyplot as plt
import numpy as np

np.random.seed(1)
data = np.random.normal(2, 3, 500)
plot = plt.boxplot(data, patch_artist=True)

color = 'green'
fill_color='lightblue'
width = 1.7

for prop in ['boxes', 'whiskers', 'means', 'medians', 'caps']:
    plt.setp(# your code here)

for prop in ['boxes']:
    plt.setp(plot[prop], facecolor=fill_color) 

plt.show()

Change the color and thickness of all lines in the boxplot with a for loop

The answer should be in the following format:

plt.setp(...)
Enter a short text
___

Create a free account to access the full topic