Error bars and array type recipes

Source code Author Update time

using Plots
gaston()
begin
    struct Measurement <: Number
        val::Float64
        err::Float64
    end
    value(m::Measurement) = begin
            m.val
        end
    uncertainty(m::Measurement) = begin
            m.err
        end
    @recipe function f(::Type{T}, m::T) where T <: AbstractArray{<:Measurement}
            if !(get(plotattributes, :seriestype, :path) in [:contour, :contourf, :contour3d, :heatmap, :surface, :wireframe, :image])
                error_sym = Symbol(plotattributes[:letter], :error)
                plotattributes[error_sym] = uncertainty.(m)
            end
            value.(m)
        end
    x = Measurement.(10 * sort(rand(10)), rand(10))
    y = Measurement.(10 * sort(rand(10)), rand(10))
    z = Measurement.(10 * sort(rand(10)), rand(10))
    surf = Measurement.((1:10) .* (1:10)', rand(10, 10))
    plot(scatter(x, [x y]), scatter(x, y, z), heatmap(x, y, surf), wireframe(x, y, surf), legend = :topleft)
end
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 2 4 6 8 10 2 4 6 8 gnuplot_plot_1a gnuplot_plot_2a gnuplot_plot_3a gnuplot_plot_4a gnuplot_plot_5a gnuplot_plot_6a gnuplot_plot_7a gnuplot_plot_8a gnuplot_plot_9a gnuplot_plot_10a gnuplot_plot_11a gnuplot_plot_12a gnuplot_plot_13a gnuplot_plot_14a gnuplot_plot_15a gnuplot_plot_16a gnuplot_plot_17a gnuplot_plot_18a gnuplot_plot_19a gnuplot_plot_20a y1 gnuplot_plot_22a gnuplot_plot_23a gnuplot_plot_24a gnuplot_plot_25a gnuplot_plot_26a gnuplot_plot_27a gnuplot_plot_28a gnuplot_plot_29a gnuplot_plot_30a gnuplot_plot_31a gnuplot_plot_32a gnuplot_plot_33a gnuplot_plot_34a gnuplot_plot_35a gnuplot_plot_36a gnuplot_plot_37a gnuplot_plot_38a gnuplot_plot_39a gnuplot_plot_40a gnuplot_plot_41a y2 gnuplot_plot_1a gnuplot_plot_2a gnuplot_plot_3a gnuplot_plot_4a gnuplot_plot_5a gnuplot_plot_6a gnuplot_plot_7a gnuplot_plot_8a gnuplot_plot_9a gnuplot_plot_10a gnuplot_plot_11a gnuplot_plot_12a gnuplot_plot_13a gnuplot_plot_14a gnuplot_plot_15a gnuplot_plot_16a gnuplot_plot_17a gnuplot_plot_18a gnuplot_plot_19a gnuplot_plot_20a y1 y1 gnuplot_plot_22a gnuplot_plot_23a gnuplot_plot_24a gnuplot_plot_25a gnuplot_plot_26a gnuplot_plot_27a gnuplot_plot_28a gnuplot_plot_29a gnuplot_plot_30a gnuplot_plot_31a gnuplot_plot_32a gnuplot_plot_33a gnuplot_plot_34a gnuplot_plot_35a gnuplot_plot_36a gnuplot_plot_37a gnuplot_plot_38a gnuplot_plot_39a gnuplot_plot_40a gnuplot_plot_41a y2 y2 gnuplot_plot_1b 2 3 4 5 6 7 8 2 4 6 8 10 0 10 20 30 40 50 60 70 80 90 100 2 4 6 8 2 4 6 8 10 2 4 6 8 10 gnuplot_plot_1c gnuplot_plot_2c gnuplot_plot_3c gnuplot_plot_4c y1 gnuplot_plot_1c gnuplot_plot_2c gnuplot_plot_3c gnuplot_plot_4c y1 2 3 4 5 6 7 8 2 4 6 8 20 40 60 80 100 gnuplot_plot_1d

This page was generated using DemoCards.jl and Literate.jl.