From c5fb4a9228bee6feeab8a64e2cd123f20410826e Mon Sep 17 00:00:00 2001 From: Josef Heinen Date: Tue, 9 Feb 2016 17:48:45 +0100 Subject: [PATCH] Added some sanity checks --- src/backends/gr.jl | 34 ++++++++++++++++++++++++++-------- src/backends/supported.jl | 1 + 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index e8dcc18e..53ee97ac 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -121,6 +121,12 @@ function gr_display(plt::Plot{GRPackage}, clear=true, update=true, end end end + if xmax <= xmin + xmax = xmin + 1 + end + if ymax <= ymin + ymax = ymin + 1 + end extrema[axis,:] = [xmin, xmax, ymin, ymax] end @@ -236,14 +242,18 @@ function gr_display(plt::Plot{GRPackage}, clear=true, update=true, GR.setfillcolorind(gr_getcolorind(p[:fillcolor])) GR.setfillintstyle(GR.INTSTYLE_SOLID) end - if p[:fillrange] != nothing - GR.fillarea([p[:x][1]; p[:x]; p[:x][length(p[:x])]], [p[:fillrange]; p[:y]; p[:fillrange]]) + if length(p[:x]) > 1 + if p[:fillrange] != nothing + GR.fillarea([p[:x][1]; p[:x]; p[:x][length(p[:x])]], [p[:fillrange]; p[:y]; p[:fillrange]]) + end + GR.polyline(p[:x], p[:y]) end - GR.polyline(p[:x], p[:y]) legend = true end if p[:linetype] == :line - GR.polyline(p[:x], p[:y]) + if length(p[:x]) > 1 + GR.polyline(p[:x], p[:y]) + end legend = true elseif p[:linetype] in [:steppre, :steppost] n = length(p[:x]) @@ -261,7 +271,9 @@ function gr_display(plt::Plot{GRPackage}, clear=true, update=true, end j += 2 end - GR.polyline(x, y) + if n > 1 + GR.polyline(x, y) + end legend = true elseif p[:linetype] == :sticks x, y = p[:x], p[:y] @@ -275,7 +287,9 @@ function gr_display(plt::Plot{GRPackage}, clear=true, update=true, if haskey(d, :markersize) if typeof(d[:markersize]) <: Number GR.setmarkersize(d[:markersize] / 4.0) - GR.polymarker(p[:x], p[:y]) + if length(p[:x]) > 0 + GR.polymarker(p[:x], p[:y]) + end else c = p[:markercolor] GR.setcolormap(-GR.COLORMAP_GLOWING) @@ -289,7 +303,9 @@ function gr_display(plt::Plot{GRPackage}, clear=true, update=true, end end else - GR.polymarker(p[:x], p[:y]) + if length(p[:x]) > 0 + GR.polymarker(p[:x], p[:y]) + end end legend = true elseif p[:linetype] == :bar @@ -419,7 +435,9 @@ function gr_display(plt::Plot{GRPackage}, clear=true, update=true, end else haskey(p, :linewidth) && GR.setlinewidth(p[:linewidth]) - GR.polyline3d(x, y, z) + if length(x) > 0 + GR.polyline3d(x, y, z) + end end GR.setlinewidth(1) GR.setcharheight(charheight) diff --git a/src/backends/supported.jl b/src/backends/supported.jl index ee7d77b9..a647a079 100644 --- a/src/backends/supported.jl +++ b/src/backends/supported.jl @@ -189,6 +189,7 @@ supportedArgs(::GRPackage) = [ :label, :layout, :legend, + :colorbar, :linestyle, :linetype, :linewidth,