Plotly Boxplot: Groupby Option?
I have two boolean variables and I try to create a boxplot with groups. Each group should represent one of the variables and it should contain two boxplots, one for TRUE and one fo
Solution 1:
You need to rearrange your data arrays so that the two Box
traces have 'x'
coordinates of 'noClassGc'
and 'aggresiveOpts'
.
This IPython notebook shows you how to do so.
Solution 2:
Alternatively, to represent each group by its boolean boxplots, you can assign each trace to different x-axes. Here is an example:
trace0 = Box(
y=raw_matrix_TPS,
x=raw_matrix_noClassGc,
name='noClassGc',
marker=Marker(
color='#3F5D7D'
)
)
trace1 = Box(
y=raw_matrix_TPS,
x=raw_matrix_aggresiveOpts,
name='aggresiveOpts',
xaxis='x2',
marker=Marker(
color='#0099FF'
)
)
data = Data([trace0, trace1])
layout = Layout(
xaxis = XAxis(
domain=[0, 0.55],
),
xaxis2 = XAxis(
domain=[0.55, 1],
),
yaxis = YAxis(
title='confidence',
zeroline=False
),
boxmode='group',
boxgroupgap=0.5
)
fig = Figure(data=data, layout=layout)
plot_url = py.plot(fig, filename='Performance by categoricals parameters')
Here is the link to the plot
To learn more, you can checkout Plotly Python reference
Post a Comment for "Plotly Boxplot: Groupby Option?"