Untitled

mail@pastecode.io avatar
unknown
plain_text
3 months ago
869 B
2
Indexable
Never
import matplotlib.pyplot as plt

# Data for cell means
cell_means = [
    [22.75, 20.50],  # Variable A Level 1
    [21.00, 21.00],  # Variable A Level 2
    [16.00, 18.00]   # Variable A Level 3
]

# Labels for x-axis (Variable B levels)
x_labels = ['Variable B Level 1', 'Variable B Level 2']

# Labels for bars (Variable A levels)
bar_labels = ['Variable A Level 1', 'Variable A Level 2', 'Variable A Level 3']

# Plotting the bar graph
fig, ax = plt.subplots()
width = 0.35  # Width of the bars

# Iterate over each level of Variable A
for i, means in enumerate(cell_means):
    x = [j + i * width for j in range(len(x_labels))]
    ax.bar(x, means, width, label=bar_labels[i])

ax.set_xticks([0.175, 1.175])
ax.set_xticklabels(x_labels)
ax.set_xlabel('Variable B Levels')
ax.set_ylabel('Cell Means')
ax.set_title('Bar Graph of Cell Means')
ax.legend()

plt.show()
Leave a Comment