Untitled
unknown
plain_text
3 years ago
616 B
5
Indexable
import pandas as pd
import matplotlib.pyplot as plt
# Create a figure with subplots
fig, ax = plt.subplots(figsize=(20, 10))
# Group data by cylinder size and create a box plot for each group
groups = cars.groupby('Cyl')
positions = range(len(groups))
for idx, (name, group) in enumerate(groups):
group.boxplot(column='Hwy MPG', positions=[positions[idx]], ax=ax, widths=0.5)
plt.xlabel('Cylinders')
plt.ylabel('Miles per Gallon')
plt.xticks(positions, [name for name, _ in groups])
print(name)
plt.title('Box Plot for all Cylinder Cars')
plt.savefig("all_BP.png")
plt.show()Editor is loading...