Merge pull request #589 from piever/pull-request/62280fb2

Allow errorbars in plots with categorical x axis (see #549 )
This commit is contained in:
Tom Breloff 2016-11-26 21:56:44 -05:00 committed by GitHub
commit 2b8cc7cfde
2 changed files with 7 additions and 2 deletions

View File

@ -526,8 +526,7 @@ end
function error_coords(xorig, yorig, ebar) function error_coords(xorig, yorig, ebar)
# init empty x/y, and zip errors if passed Tuple{Vector,Vector} # init empty x/y, and zip errors if passed Tuple{Vector,Vector}
x, y = zeros(0), zeros(0) x, y = Array(float_extended_type(xorig), 0), Array(Float64, 0)
# for each point, create a line segment from the bottom to the top of the errorbar # for each point, create a line segment from the bottom to the top of the errorbar
for i = 1:max(length(xorig), length(yorig)) for i = 1:max(length(xorig), length(yorig))
xi = cycle(xorig, i) xi = cycle(xorig, i)

View File

@ -228,6 +228,12 @@ function Base.next(itr::SegmentsIterator, nextidx::Int)
istart:iend, i istart:iend, i
end end
# Find minimal type that can contain NaN and x
# To allow use of NaN separated segments with categorical x axis
float_extended_type{T}(x::AbstractArray{T}) = Union{T,Float64}
float_extended_type{T<:Real}(x::AbstractArray{T}) = Float64
# ------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------