# How to plot mean +/- deviation in Plots.jl?

**URL:** <https://discourse.julialang.org/t/how-to-plot-mean-deviation-in-plots-jl/1975>\
**Category:** Visualization\
**Tags:** question, plotting\
**Created:** [February 8, 2017, 7:08am UTC](https://discourse.julialang.org/t/how-to-plot-mean-deviation-in-plots-jl/1975 "2017-02-08T07:08:32Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![thompsonmj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thompsonmj/32/25172_2.png) [@thompsonmj](https://discourse.julialang.org/u/thompsonmj)\
**Post date:** [June 15, 2021, 4:02pm UTC](https://discourse.julialang.org/t/how-to-plot-mean-deviation-in-plots-jl/1975/21 "2021-06-15T16:02:06Z")

</div>

Piggybacking on this question … is there a way to get `ribbon` (or a similar filled error bounds plotting tool) to work with data containing `NaN` values?

---

<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:** [June 15, 2021, 5:07pm UTC](https://discourse.julialang.org/t/how-to-plot-mean-deviation-in-plots-jl/1975/22 "2021-06-15T17:07:58Z")

</div>

@thompsonmj, this works with gr() back-end but one may need to add some more NaN to avoid leakage:

```julia
using Plots; gr()

xs = collect(LinRange(1,20,50))
ys, σs = log.(xs), rand(length(xs))
xs[10] = NaN; ys[20] = NaN; σs[30] = NaN;
ix = union(findall(isnan,xs), findall(isnan,ys), findall(isnan,σs))
xs[ix] .= NaN; ys[ix] .= NaN; σs[ix] .= NaN; 
Plots.plot( xs,ys, color=:lightblue, ribbon=σs,label=false)
Plots.plot!(xs,ys, color=:blue, marker=(:circle, 7, 1.),label=false)

```

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

---

<div class="post-metadata">

**Author:** ![thompsonmj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thompsonmj/32/25172_2.png) [@thompsonmj](https://discourse.julialang.org/u/thompsonmj)\
**Post date:** [June 15, 2021, 6:07pm UTC](https://discourse.julialang.org/t/how-to-plot-mean-deviation-in-plots-jl/1975/23 "2021-06-15T18:07:05Z")

</div>

OK, so x and y values just need to have NaN in corresponding indices for the data assigned to the ribbon. Thank you!

[Previous page](https://discourse.julialang.org/t/how-to-plot-mean-deviation-in-plots-jl/1975.md?page=1)
