I followed the examples on this link on how to create a boxplot with colors. I have been trying different ways to separate these boxplots on two different positions instead of both of them overlapping but to no avail. If I specify different positions for both of them, they stay on the bp2 position. How do I put these two boxplots side by side?
import matplotlib.pyplot as plt
def color_boxplot(data, color):
bp = boxplot(data, patch_artist=True, showmeans=True)
for item in ['boxes', 'whiskers', 'fliers', 'medians', 'caps']:
plt.setp(bp[item], color=color)
data1 = [1, 2, 3, 4, 5]
data2 = [4, 5, 6, 7, 8]
fig, ax = plt.subplots()
bp1 = color_boxplot(data1, 'green')
bp2 = color_boxplot(data2, 'red')
plt.show()
EDIT: Added sample data.