# How to add significance stars to a Plotly boxplot

**URL:** <https://discourse.julialang.org/t/how-to-add-significance-stars-to-a-plotly-boxplot/81170>\
**Category:** Visualization\
**Tags:** plotting, plotlyjs\
**Created:** [May 16, 2022, 7:41pm UTC](https://discourse.julialang.org/t/how-to-add-significance-stars-to-a-plotly-boxplot/81170 "2022-05-16T19:41:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juan\_Mac\_Donagh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juan_mac_donagh/32/31798_2.png) [@Juan\_Mac\_Donagh](https://discourse.julialang.org/u/Juan_Mac_Donagh)\
**Post date:** [May 16, 2022, 7:41pm UTC](https://discourse.julialang.org/t/how-to-add-significance-stars-to-a-plotly-boxplot/81170/1 "2022-05-16T19:41:25Z")

</div>

Hi all, I have the following boxplot that I made with Plotly, and I was wondering if there was a general way of adding the significance asterisks above them? I have already done the statistic test, so I only have to add them by hand.

![Desorder rates of TR-BRP, TR & Reference](https://global.discourse-cdn.com/julialang/original/3X/6/a/6ac9ac368eb229b2e960a9805e3fb03436d04812.png)

Here’s my code:

```julia
begin
	x_data=name_bx_tr #names of the boxplots
	y_data=(dn7bx_tr_rna,dn7bx_tr, dn7bx_tr_anti) #data
	color_vec = ["rgba(93, 164, 214, 0.5)", "rgba(255, 144, 14, 0.5)", "rgba(207, 114, 255, 0.5)"]

	traces = [
    	box(
        	y=yd,
        	name=xd,
        	boxpoints="all",
        	jitter=0.5,
        	whiskerwidth=0.2,
        	fillcolor=cls,
        	marker_size=2,
        	line_width=1,

    	)
    	for (xd, yd, cls) in zip(x_data, y_data, color_vec)
	]

	layout = Layout(
    	title="Evolutionary rates of RBP-TR, TR and Reference proteins",
    	yaxis=attr(
        	autorange=true,
        	showgrid=true,
        	zerline=true,
        	dtick=5,
        	gridcolor="rgb(255,255,255)",
        	zerlinecolor="rgb(255,255,255)",
        	zerolinewidth=2
    	),
    	margin=attr(
        	l=40,
        	r=30,
        	b=80,
        	t=100
    	),
    	paper_bgcolor="rgb(243,243,243)",
    	plot_bgcolor="rgb(243,243,243)",
    	showlegend=false,
		height=400
	)

	Plot(traces, layout)
end

```

I supuse it goes somewhere on layout, but it is not documented at all in their page.

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![halleysfifthinc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/halleysfifthinc/32/206280_2.png) [@halleysfifthinc](https://discourse.julialang.org/u/halleysfifthinc)\
**Post date:** [May 16, 2022, 8:48pm UTC](https://discourse.julialang.org/t/how-to-add-significance-stars-to-a-plotly-boxplot/81170/2 "2022-05-16T20:48:59Z")

</div>

There is no general (ie smart/automatic) way to add significance asterisks or brackets in Plotly. Use [`shapes`](https://plotly.com/javascript/reference/layout/shapes/) for brackets and [`annotations`](https://plotly.com/javascript/reference/layout/annotations/) for asterisks/daggers/etc.

This helper function I wrote previously for making the bracket shape may be of use to you:

```julia
function bracket(xcent, width, y, yoffset, legheight; yref="y")
    path("""
            M $(xcent - width/2) $(y + yoffset - legheight)
            V $(y + yoffset)
            H $(xcent + width/2)
            V $(y + yoffset - legheight)
        """; xref="paper", yref=yref, line_width=1.5)
end

```

---

<div class="post-metadata">

**Author:** ![Juan\_Mac\_Donagh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juan_mac_donagh/32/31798_2.png) [@Juan\_Mac\_Donagh](https://discourse.julialang.org/u/Juan_Mac_Donagh)\
**Post date:** [May 17, 2022, 2:15pm UTC](https://discourse.julialang.org/t/how-to-add-significance-stars-to-a-plotly-boxplot/81170/3 "2022-05-17T14:15:29Z")

</div>

Thanks! I am not sure how to use the function yet, could you provide a simple example if it is not too much trouble?

---

<div class="post-metadata">

**Author:** ![Juan\_Mac\_Donagh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juan_mac_donagh/32/31798_2.png) [@Juan\_Mac\_Donagh](https://discourse.julialang.org/u/Juan_Mac_Donagh)\
**Post date:** [May 17, 2022, 3:30pm UTC](https://discourse.julialang.org/t/how-to-add-significance-stars-to-a-plotly-boxplot/81170/4 "2022-05-17T15:30:15Z")

</div>

Ops, I already figured it out, just needed a little more time. Plotly is kinda new for me. Thanks a lot!!
