When making a box plot, the easiest place to start is the line that is inside the box. This line is the median of the dataset. Half of the data falls above that line and half falls below it.

We can find the median of a dataset by using NumPy’s median() function.

import numpy as np dataset = [4, 8, 15, 16, 23] dataset_median = np.median(dataset) # dataset_median stores the value 15



Over the next few exercises, we’re going to build a boxplot by hand, using an example dataset.

We’ve imported a dataset named dataset. Create a variable named dataset_median. Use NumPy’s median() function to set dataset_median equal to the median of the dataset.


After running the code, you should see the median print to the terminal. Using that value, draw the a line in the browser at the correct location.

You can refresh the browser component if you want to re-draw the line.

When you’re ready to move on, run your code one more time and then click the next button!

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?