# Adding Error Bars To Legend

**URL:** https://discourse.julialang.org/t/adding-error-bars-to-legend/79018
**Category:** Visualization
**Tags:** plots
**Created:** [April 4, 2022, 7:02pm UTC](https://discourse.julialang.org/t/adding-error-bars-to-legend/79018 "2022-04-04T19:02:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![cmdenis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cmdenis/32/211517_2.png) [@cmdenis](https://discourse.julialang.org/u/cmdenis)
#### Post date: [April 4, 2022, 7:02pm UTC](https://discourse.julialang.org/t/adding-error-bars-to-legend/79018/1 "2022-04-04T19:02:58Z")

</div>

Hi,

I’m trying to make a plot (with Plots) with some data points. I’d like to be able to add an entry to the legend labeling the error bars.

So far I have something of the sort:

```julia
scatter(
    rand(10),
    yerr = rand(10) ./ 10,
    label = "Data Points"
)

```

Is there any way of having an extra row in my legend with something like a cross next to another labeling for the error bars?

Thanks!

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [April 4, 2022, 7:28pm UTC](https://discourse.julialang.org/t/adding-error-bars-to-legend/79018/2 "2022-04-04T19:28:15Z")

</div>

One way with no bells and whistles:

```julia
using Plots; gr()
p = scatter(rand(10), yerr = rand(10)/10, label="Data Points", c=:blues)
scatter!([-1],[NaN], xlims=xlims(p), ylims=(-0.5,2), label=" ")
scatter!([-1],[-1], xlims=xlims(p), shape=:cross, label="Error bars", c=:black)

```

 ![Plots_gr_add_error_bars_to_legend](https://global.discourse-cdn.com/julialang/original/3X/f/4/f4a49c2def11cba146b3d6d8c850e95e2f39b908.png)

---

<div class="post-metadata">

### Author: ![cmdenis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cmdenis/32/211517_2.png) [@cmdenis](https://discourse.julialang.org/u/cmdenis)
#### Post date: [April 6, 2022, 7:18pm UTC](https://discourse.julialang.org/t/adding-error-bars-to-legend/79018/3 "2022-04-06T19:18:52Z")

</div>

Alright thanks! I’ll be using that!
