Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support explicit empty arrays #1392

Merged
merged 2 commits into from
Feb 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/coord.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function first_concrete_aesthetic_value(aess::Vector{Gadfly.Aesthetics}, vars::V
end
end

return nothing
return missing
end


Expand Down Expand Up @@ -156,7 +156,7 @@ function apply_coordinate(coord::Cartesian, aess::Vector{Gadfly.Aesthetics},

xmin = xmax = first_concrete_aesthetic_value(aess, coord.xvars)

if xmin != nothing
if !ismissing(xmin)
for var in coord.xvars
for aes in aess
vals = getfield(aes, var)
Expand All @@ -172,7 +172,7 @@ function apply_coordinate(coord::Cartesian, aess::Vector{Gadfly.Aesthetics},
end

ymin = ymax = first_concrete_aesthetic_value(aess, coord.yvars)
if ymin != nothing
if !ismissing(ymin)
for var in coord.yvars
for aes in aess
vals = getfield(aes, var)
Expand Down Expand Up @@ -216,23 +216,23 @@ function apply_coordinate(coord::Cartesian, aess::Vector{Gadfly.Aesthetics},
end
end

xmax = xviewmax === nothing ? xmax : max(xmax, xviewmax)
xmin = xviewmin === nothing ? xmin : min(xmin, xviewmin)
ymax = yviewmax === nothing ? ymax : max(ymax, yviewmax)
ymin = yviewmin === nothing ? ymin : min(ymin, yviewmin)
xmax = xviewmax === nothing ? xmax : maximum(skipmissing([xmax; xviewmax]))
xmin = xviewmin === nothing ? xmin : minimum(skipmissing([xmin; xviewmin]))
ymax = yviewmax === nothing ? ymax : maximum(skipmissing([ymax; yviewmax]))
ymin = yviewmin === nothing ? ymin : minimum(skipmissing([ymin; yviewmin]))

# Hard limits set in Coord should override everything else
xmin = coord.xmin === nothing ? xmin : coord.xmin
xmax = coord.xmax === nothing ? xmax : coord.xmax
ymin = coord.ymin === nothing ? ymin : coord.ymin
ymax = coord.ymax === nothing ? ymax : coord.ymax

if xmin === nothing || isa(xmin, Measure) || !isfinite(xmin)
if ismissing(xmin) || isa(xmin, Measure) || !isfinite(xmin)
xmin = 0.0
xmax = 1.0
end

if ymin === nothing || isa(ymin, Measure) || !isfinite(ymin)
if ismissing(ymin) || isa(ymin, Measure) || !isfinite(ymin)
ymin = 0.0
ymax = 1.0
end
Expand Down
8 changes: 4 additions & 4 deletions src/statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ function apply_statistic(stat::TickStatistic,
for var in in_vars
categorical && !in(var,[:x,:y]) && continue
vals = getfield(aes, var)
if vals != nothing && eltype(vals) != Function
if valsnothing && !isempty(vals) && eltype(vals)≠Function
vv = [vals; minval; maxval]
if in(var, [:x, :y])
sizeflag && (vv = vec([x+s*d for (x, d) in cyclezip(vals, size), s in [-1.0, 1.0]]))
Expand All @@ -848,14 +848,14 @@ function apply_statistic(stat::TickStatistic,
end
end

isempty(in_vals) && return
isempty(in_vals) && stat.ticks==:auto && return

in_vals = Iterators.flatten(in_vals)

# consider forced tick marks
if stat.ticks != :auto
minval = min(minval, minimum(stat.ticks))
maxval = max(maxval, maximum(stat.ticks))
minval = minimum(skipmissing([minval;stat.ticks]))
maxval = maximum(skipmissing([maxval;stat.ticks]))
end

# TODO: handle the outliers aesthetic
Expand Down
12 changes: 12 additions & 0 deletions test/testscripts/issue751.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Gadfly

set_default_plot_size(6.6inch, 3.3inch)

p1 = plot(x=[], y=[], Geom.point)
p2 = plot(x=[], y=[], Geom.line,
Guide.xticks(ticks=[0,10]), Guide.yticks(ticks=[0,10])
)

hstack(p1,p2)