I would like to plot a function test(x) with an error bar, where the magnitude of the corresponding errors are saved in the function error_bar_test(x).
The Plot should look like this:
I would like to plot a function test(x) with an error bar, where the magnitude of the corresponding errors are saved in the function error_bar_test(x).
The Plot should look like this:
Do you have a particular plotting library in mind? Here's a solution with Plots.jl:
ulia> using Plots
julia> plot(0:2, [6, 10, 2], yerr = [1, 2, 3], msc = 1, label = "", ytick = 0:2:12)
so you need to pass a two vectors with your x and y values and then a vector of the same length as the yerr keyword arg. I've also changed the color of the errorbars and the default values of the yticks as well as removed the automatic label for the series. This gives:
Another convenient way is to combine Plots.jl with Measurements.jl:
using Plots, Measurements
plot(0:2, [6, 10, 2] .± [1, 2, 3])
produces