1

I am trying to create a series of sub plots each containing box plots using Plotly. At the moment I have managed to create the following plot;

plot.

Unfortunately, this is not exactly what I want. I would like to create a subplot for S1 and S2 rather than A1 and A2 (such that each sub plot will have a green box plot and a red box plot).

Is this possible?

This is my current code.

x = ['S1', 'S1', 'S1', 'S1', 'S1', 'S1',
     'S2', 'S2', 'S2', 'S2', 'S2', 'S2']

trace0 = go.Box(
    y=[1.935, 2.59, 2.97, 2.97, 3.28, 4.315, 1.935, 2.59, 2.97, 2.97, 3.28, 4.315],
    x=x,
    name='A1',
    marker=dict(
        color='#3D9970'
    )
)
trace1 = go.Box(
    y=[0.6, 0.7, 0.3, 0.6, 0.0, 0.5, 0.7, 0.9, 0.5, 0.8, 0.7, 0.2],
    x=x,
    name='A2',
    marker=dict(
        color='#FF4136'
    )
)
fig = tools.make_subplots(rows=1, cols=2)
fig.append_trace(trace0, 1, 1)
fig.append_trace(trace1, 1, 2)
py.iplot(fig)
  • Did you try arranging your data differently? i.e. all S1 data in the first plot and all S2 data in the second plot. – Maximilian Peters Apr 21 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.