Changing the line width of error bars

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.:

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

The solution is to use attribute “markerstrokewidth”

1 Like

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?

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

creates
image

Some info

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

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

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

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.)

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:

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)