Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
616 B
1
Indexable
Never
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()