105k views
3 votes
Code for creating box plot in python

User Gop
by
7.9k points

1 Answer

5 votes

Answer: Here's an example code:

import matplotlib.pyplot as plt

import numpy as np

# Generate sample data

data = [np.random.normal(0, std, 100) for std in range(1, 4)]

# Create a box plot

plt.boxplot(data, vert=True, patch_artist=True)

# Add title and labels

plt.title('Box plot of sample data')

plt.xlabel('Sample')

plt.ylabel('Value')

# Show the plot

plt.show()

User Glaucon
by
7.1k points