# Changing the line width of error bars

**URL:** https://discourse.julialang.org/t/changing-the-line-width-of-error-bars/34489
**Category:** General Usage
**Tags:** plotting, plots
**Created:** [February 11, 2020, 9:12pm UTC](https://discourse.julialang.org/t/changing-the-line-width-of-error-bars/34489 "2020-02-11T21:12:47Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![yanivab](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yanivab/32/9164_2.png) [@yanivab](https://discourse.julialang.org/u/yanivab)
#### Post date: [February 11, 2020, 9:12pm UTC](https://discourse.julialang.org/t/changing-the-line-width-of-error-bars/34489/1 "2020-02-11T21:12:47Z")

</div>

Using Plots.jl, I know how to change the line width for the data with attribute “linewidth”. But this does not change the thickness of the lines comprising the error bar. How does one change those?

e.g.:

```julia
@df dat plot(:x, :y, yerror = :se, lw = 2)

```

---

<div class="post-metadata">

### Author: ![yanivab](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yanivab/32/9164_2.png) [@yanivab](https://discourse.julialang.org/u/yanivab)
#### Post date: [February 11, 2020, 9:45pm UTC](https://discourse.julialang.org/t/changing-the-line-width-of-error-bars/34489/2 "2020-02-11T21:45:26Z")

</div>

The solution is to use attribute “markerstrokewidth”

---

<div class="post-metadata">

### Author: ![Gabriel\_Kreindler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gabriel_kreindler/32/24961_2.png) [@Gabriel\_Kreindler](https://discourse.julialang.org/u/Gabriel_Kreindler)
#### Post date: [February 23, 2023, 6:43pm UTC](https://discourse.julialang.org/t/changing-the-line-width-of-error-bars/34489/3 "2023-02-23T18:43:10Z")

</div>

This no longer works for me, in the sense that I’d like `markerstrokewidth` to override `linewidth`. It used to do this a short while ago but no longer?

```julia
using Plots
plot([1,2], [4,5], yerror=[0.1,0.2], markerstrokewidth=1, linewidth=5)

```

creates  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/1/b/1ba03d7f54ed3251e4776d82ee930877dae892bc.png)

Some info

```julia
julia> versioninfo()
Julia Version 1.8.1
Commit afb6c60d69 (2022-09-06 15:09 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 24 × 12th Gen Intel(R) Core(TM) i9-12900KF
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, goldmont)
  Threads: 1 on 24 virtual cores
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 

(@v1.8) pkg> st --manifest Plots
Status `C:\Users\Gabriel Kreindler\.julia\environments\v1.8\Manifest.toml`
  [91a5bcdd] Plots v1.38.5

```

---

<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: [February 24, 2023, 9:50am UTC](https://discourse.julialang.org/t/changing-the-line-width-of-error-bars/34489/4 "2023-02-24T09:50:00Z")

</div>

You may achieve what you would like but with a multi blade razor:

```julia
using Plots
plot([1,2], [4,5], yerror=[0.1,0.2], msw=2, lw=1)
plot!([1,2], [4,5], lw=3)

```

---

<div class="post-metadata">

### Author: ![Gabriel\_Kreindler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gabriel_kreindler/32/24961_2.png) [@Gabriel\_Kreindler](https://discourse.julialang.org/u/Gabriel_Kreindler)
#### Post date: [February 24, 2023, 11:54am UTC](https://discourse.julialang.org/t/changing-the-line-width-of-error-bars/34489/5 "2023-02-24T11:54:34Z")

</div>

Thank you, this is what I ended up doing!

Still, it would be useful to have the separate linewidth option for the `yerror` error bars. The current solution is not completely ideal, for example when we also want something like `linestyle=:dash`. (I ended up using `linecolor=:white` for the first plot.)

---

<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: [February 24, 2023, 12:31pm UTC](https://discourse.julialang.org/t/changing-the-line-width-of-error-bars/34489/6 "2023-02-24T12:31:09Z")

</div>

For that scenario, the following code works but generates a warning message that I have not yet managed to resolve concerning the vector of colors:

```julia
using Plots
x, y, ey = [1,2], [4,5], [0.1,0.2]
plot( x, y, yerror=ey, msw=2, lw=1, lc=[:white, :black, :black])
plot!(x, y, lc=:blue, lw=3, ls=:dash)

```
