How to add an extra point over a boxplot graph with plotly?

Viewed 234

I am trying to overlay a point over a boxplot with Plotly and Python. I am able to add two traces to the same graph, but I couldn't find a way to make the extra point closer to the boxplot.

This is the image I get:

An image depicting the described boxplot with two traces and two points - one blue (to the left) and one red (up and to the right)

and the code that generates it is:

x = np.fromiter(duplicates.values(), dtype=float)

fig = go.Figure()
fig.update_layout(autosize=False, width=400, height=150, paper_bgcolor="White", plot_bgcolor='rgba(0,0,0,0)',
                  hovermode=False, margin=dict(l=10, r=10, b=10, t=10, pad=4),
                  boxmode='group',  boxgroupgap=0.25,
                  boxgap=0.25,
                  )
fig.add_trace(go.Box(x=x, showlegend=False))
fig.add_trace(go.Scatter(x=np.array(duplicates[sample_id]), y=np.array(0), mode='markers', showlegend=False))
fig.update_xaxes(title='')
fig.update_yaxes(showticklabels=False)

my_div = plotly.offline.plot(fig, output_type='div',
                             show_link=False,
                             config=dict(
                                 displayModeBar=False
                             ))
0 Answers
Related