import matplotlib.pyplot as plt
import pandas as pd
import io
csv = '''
ID,group,time,success
P1,control,18.6,1
P2,control,15.42,1
P3,control,25.55,0
P4,control,12.56,0
P5,control,8.67,1
P6,experiment,7.31,0
P7,experiment,9.66,0
P8,experiment,13.64,1
P9,experiment,14.92,1
P10,experiment,18.47,1
'''
df = pd.read_csv(io.StringIO(csv))
# create a box plot where each box refers to a group
df.boxplot(column='time', by='group')
# remove the grid and increase the limit of y axis to 30
plt.grid(False)
plt.ylim(0, 30)
# add a dashed horizontal line at y=25
plt.axhline(y=25, linestyle='--')
# add a label "limit" next to the horizontal line
plt.text(x=2.45, y=25.5, s='limit')
# for each group, add scatter dots on top of the box using the time data, and mark the dots with blue if success=1, otherwise red
markers = ['o', 'x']
colors = ['blue', 'red']
for i, group in df.groupby('group'):
for j, (marker, color) in enumerate(zip(markers, colors)):
x = j + 1
y = group ['time'][group ['success'] == j]
plt.scatter(x, y, marker=marker, color=co
lor)
There is a runtime error according to the output panel. However, instead of being displayed inside PB, the runtime error is not reported, and we have rv=None instead.
Can replicate both locally and in the web version.
To replicate:
lor)
There is a runtime error according to the output panel. However, instead of being displayed inside PB, the runtime error is not reported, and we have
rv=None
instead.Can replicate both locally and in the web version.