ribbons; changed errorbar to yerror and added xerror
This commit is contained in:
parent
3c3078875a
commit
61e34b7ef8
12
src/args.jl
12
src/args.jl
@ -145,7 +145,9 @@ _seriesDefaults[:zcolor] = nothing # value for color scale
|
|||||||
# _seriesDefaults[:nlevels] = 15
|
# _seriesDefaults[:nlevels] = 15
|
||||||
_seriesDefaults[:levels] = 15
|
_seriesDefaults[:levels] = 15
|
||||||
_seriesDefaults[:orientation] = :vertical
|
_seriesDefaults[:orientation] = :vertical
|
||||||
_seriesDefaults[:errorbar] = nothing
|
_seriesDefaults[:xerror] = nothing
|
||||||
|
_seriesDefaults[:yerror] = nothing
|
||||||
|
_seriesDefaults[:ribbon] = nothing
|
||||||
|
|
||||||
|
|
||||||
const _plotDefaults = KW()
|
const _plotDefaults = KW()
|
||||||
@ -325,8 +327,12 @@ end
|
|||||||
:clearfig => :overwrite_figure,
|
:clearfig => :overwrite_figure,
|
||||||
:overwrite => :overwrite_figure,
|
:overwrite => :overwrite_figure,
|
||||||
:reuse => :overwrite_figure,
|
:reuse => :overwrite_figure,
|
||||||
:err => :errorbar,
|
:err => :yerror,
|
||||||
:error => :errorbar,
|
:errorbar => :yerror,
|
||||||
|
:xerr => :xerror,
|
||||||
|
:xerrorbar => :xerror,
|
||||||
|
:yerr => :yerror,
|
||||||
|
:yerrorbar => :yerror,
|
||||||
)
|
)
|
||||||
|
|
||||||
# add all pluralized forms to the _keyAliases dict
|
# add all pluralized forms to the _keyAliases dict
|
||||||
|
|||||||
@ -77,7 +77,9 @@ supportedArgs(::GadflyBackend) = [
|
|||||||
:grid,
|
:grid,
|
||||||
# :surface,
|
# :surface,
|
||||||
:levels,
|
:levels,
|
||||||
:errorbar,
|
:xerror,
|
||||||
|
:yerror,
|
||||||
|
:ribbon,
|
||||||
:orientation,
|
:orientation,
|
||||||
]
|
]
|
||||||
supportedAxes(::GadflyBackend) = [:auto, :left]
|
supportedAxes(::GadflyBackend) = [:auto, :left]
|
||||||
@ -166,7 +168,9 @@ supportedArgs(::PyPlotBackend) = [
|
|||||||
:linealpha,
|
:linealpha,
|
||||||
:markeralpha,
|
:markeralpha,
|
||||||
:overwrite_figure,
|
:overwrite_figure,
|
||||||
:errorbar,
|
:xerror,
|
||||||
|
:yerror,
|
||||||
|
:ribbon,
|
||||||
:orientation,
|
:orientation,
|
||||||
]
|
]
|
||||||
supportedAxes(::PyPlotBackend) = _allAxes
|
supportedAxes(::PyPlotBackend) = _allAxes
|
||||||
@ -242,7 +246,9 @@ supportedArgs(::GRBackend) = [
|
|||||||
:fillalpha,
|
:fillalpha,
|
||||||
:linealpha,
|
:linealpha,
|
||||||
:markeralpha,
|
:markeralpha,
|
||||||
:errorbar,
|
:xerror,
|
||||||
|
:yerror,
|
||||||
|
:ribbon,
|
||||||
:orientation,
|
:orientation,
|
||||||
]
|
]
|
||||||
supportedAxes(::GRBackend) = _allAxes
|
supportedAxes(::GRBackend) = _allAxes
|
||||||
@ -566,7 +572,9 @@ supportedArgs(::PlotlyBackend) = [
|
|||||||
:legendfont,
|
:legendfont,
|
||||||
:grid,
|
:grid,
|
||||||
:levels,
|
:levels,
|
||||||
:errorbar,
|
:xerror,
|
||||||
|
:yerror,
|
||||||
|
:ribbon,
|
||||||
:orientation,
|
:orientation,
|
||||||
]
|
]
|
||||||
supportedAxes(::PlotlyBackend) = [:auto, :left]
|
supportedAxes(::PlotlyBackend) = [:auto, :left]
|
||||||
@ -638,7 +646,9 @@ supportedArgs(::PlotlyJSBackend) = [
|
|||||||
:legendfont,
|
:legendfont,
|
||||||
:grid,
|
:grid,
|
||||||
:levels,
|
:levels,
|
||||||
:errorbar,
|
:xerror,
|
||||||
|
:yerror,
|
||||||
|
:ribbon,
|
||||||
:orientation,
|
:orientation,
|
||||||
]
|
]
|
||||||
supportedAxes(::PlotlyJSBackend) = [:auto, :left]
|
supportedAxes(::PlotlyJSBackend) = [:auto, :left]
|
||||||
|
|||||||
@ -140,28 +140,15 @@ end
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Error Bars
|
# Error Bars
|
||||||
|
|
||||||
|
function error_style!(d::KW)
|
||||||
# we will create a series of path segments, where each point represents one
|
|
||||||
# side of an errorbar
|
|
||||||
function apply_series_recipe(d::KW, ::Type{Val{:errorbar}})
|
|
||||||
d[:linetype] = :path
|
d[:linetype] = :path
|
||||||
d[:markershape] = isvertical(d) ? :hline : :vline
|
|
||||||
d[:linecolor] = d[:markerstrokecolor]
|
d[:linecolor] = d[:markerstrokecolor]
|
||||||
d[:linewidth] = d[:markerstrokewidth]
|
d[:linewidth] = d[:markerstrokewidth]
|
||||||
d[:label] = ""
|
d[:label] = ""
|
||||||
|
|
||||||
# to simplify: when orientation is horizontal, x/y are swapped
|
|
||||||
ebar = pop!(d, :errorbar)
|
|
||||||
xorig, yorig = d[:x], d[:y]
|
|
||||||
if !isvertical(d)
|
|
||||||
xorig, yorig = yorig, xorig
|
|
||||||
end
|
end
|
||||||
# dumpdict(d, "err", true)
|
|
||||||
# @show isvertical(d) xorig yorig ebar
|
|
||||||
|
|
||||||
# now assume vertical orientation
|
function error_coords(xorig, yorig, ebar)
|
||||||
x, y = zeros(0), zeros(0)
|
x, y = zeros(0), zeros(0)
|
||||||
w = 0.3 * mean(diff(x))
|
|
||||||
for i = 1:max(length(xorig), length(yorig))
|
for i = 1:max(length(xorig), length(yorig))
|
||||||
# create a line segment from the bottom to the top of the errorbar
|
# create a line segment from the bottom to the top of the errorbar
|
||||||
xi = get_mod(xorig, i)
|
xi = get_mod(xorig, i)
|
||||||
@ -170,8 +157,22 @@ function apply_series_recipe(d::KW, ::Type{Val{:errorbar}})
|
|||||||
nanappend!(x, [xi, xi])
|
nanappend!(x, [xi, xi])
|
||||||
nanappend!(y, [yi - ebi, yi + ebi])
|
nanappend!(y, [yi - ebi, yi + ebi])
|
||||||
end
|
end
|
||||||
|
x, y
|
||||||
|
end
|
||||||
|
|
||||||
d[:x], d[:y] = isvertical(d) ? (x, y) : (y, x)
|
# we will create a series of path segments, where each point represents one
|
||||||
|
# side of an errorbar
|
||||||
|
function apply_series_recipe(d::KW, ::Type{Val{:yerror}})
|
||||||
|
error_style!(d)
|
||||||
|
d[:markershape] = :hline
|
||||||
|
d[:x], d[:y] = error_coords(d[:x], d[:y], d[:yerror])
|
||||||
|
KW[d]
|
||||||
|
end
|
||||||
|
|
||||||
|
function apply_series_recipe(d::KW, ::Type{Val{:xerror}})
|
||||||
|
error_style!(d)
|
||||||
|
d[:markershape] = :vline
|
||||||
|
d[:y], d[:x] = error_coords(d[:y], d[:x], d[:xerror])
|
||||||
KW[d]
|
KW[d]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -151,10 +151,19 @@ function build_series_args(plt::AbstractPlot, kw::KW) #, idxfilter)
|
|||||||
d[:fillrange] = map(d[:fillrange], d[:x])
|
d[:fillrange] = map(d[:fillrange], d[:x])
|
||||||
end
|
end
|
||||||
|
|
||||||
# handle error bars and ribbons
|
# handle error bars
|
||||||
if get(d, :errorbar, nothing) != nothing
|
for esym in (:xerror, :yerror)
|
||||||
|
if get(d, esym, nothing) != nothing
|
||||||
# we make a copy of the KW and apply an errorbar recipe
|
# we make a copy of the KW and apply an errorbar recipe
|
||||||
append!(ret, apply_series_recipe(copy(d), Val{:errorbar}))
|
append!(ret, apply_series_recipe(copy(d), Val{esym}))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# handle ribbons
|
||||||
|
if get(d, :ribbon, nothing) != nothing
|
||||||
|
# append!(ret, apply_series_recipe(copy(d), Val{:ribbon}))
|
||||||
|
rib = d[:ribbon]
|
||||||
|
d[:fillrange] = (d[:y] - rib, d[:y] + rib)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user