From 65173e6dd2de3c605bb0a382c2ffca32e0da482f Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Thu, 2 May 2019 12:48:06 +0200 Subject: [PATCH] fix recipe error --- src/backends/gr.jl | 4 ++-- src/backends/pyplot.jl | 16 +++++++++------- src/utils.jl | 4 +++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 69b278fd..e9aea7d5 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -784,7 +784,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) tbx, tby = gr_inqtext(0, 0, string(lab)) legendw = max(legendw, tbx[3] - tbx[1]) end - + GR.setscale(1) GR.selntran(1) GR.restorestate() @@ -1139,7 +1139,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) end if st in (:path, :scatter, :straightline) - if length(x) > 1 + if x != nothing && length(x) > 1 lz = series[:line_z] segments = iter_segments(series) # do area fill diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 3618412f..624c01f9 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -216,13 +216,15 @@ end # --------------------------------------------------------------------------- function fix_xy_lengths!(plt::Plot{PyPlotBackend}, series::Series) - x, y = series[:x], series[:y] - nx, ny = length(x), length(y) - if !isa(get(series.plotattributes, :z, nothing), Surface) && nx != ny - if nx < ny - series[:x] = Float64[x[mod1(i,nx)] for i=1:ny] - else - series[:y] = Float64[y[mod1(i,ny)] for i=1:nx] + if series[:x] != nothing + x, y = series[:x], series[:y] + nx, ny = length(x), length(y) + if !isa(get(series.plotattributes, :z, nothing), Surface) && nx != ny + if nx < ny + series[:x] = Float64[x[mod1(i,nx)] for i=1:ny] + else + series[:y] = Float64[y[mod1(i,ny)] for i=1:nx] + end end end end diff --git a/src/utils.jl b/src/utils.jl index 2d8172f5..6a8cb81e 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -194,7 +194,9 @@ end function iter_segments(series::Series) x, y, z = series[:x], series[:y], series[:z] - if has_attribute_segments(series) + if x == nothing + return UnitRange{Int}[] + elseif has_attribute_segments(series) if series[:seriestype] in (:scatter, :scatter3d) return [[i] for i in 1:length(y)] else