diff --git a/src/bincount.jl b/src/bincount.jl index f13d90349..88525ece9 100644 --- a/src/bincount.jl +++ b/src/bincount.jl @@ -243,8 +243,8 @@ function choose_bin_count_2d(xs::AbstractVector, ys::AbstractVector, end # bin widths - wx = (x_max - x_min) / dx - wy = (y_max - y_min) / dy + wx = (x_max==x_min) ? 1.0 : (x_max - x_min) / dx + wy = (y_max==y_min) ? 1.0 : (y_max - y_min) / dy bincounts = zeros(Int, (dy, dx)) for (x, y) in zip(xs, ys) diff --git a/src/statistics.jl b/src/statistics.jl index c633af00b..068df2597 100644 --- a/src/statistics.jl +++ b/src/statistics.jl @@ -622,9 +622,11 @@ function apply_statistic(stat::Histogram2DStatistic, xminbincount, xmaxbincount, yminbincount, ymaxbincount) - wx = x_categorial ? 1 : (x_max - x_min) / dx - wy = y_categorial ? 1 : (y_max - y_min) / dy - + wx = (x_max==x_min) ? 1.0 : (x_max - x_min) / dx + wy = (y_max==y_min) ? 1.0 : (y_max - y_min) / dy + !x_categorial && (x_max==x_min) && (x_min-=0.5) + !y_categorial && (y_max==y_min) && (y_min-=0.5) + n = 0 for cnt in bincounts if cnt > 0 diff --git a/test/testscripts/issue860.jl b/test/testscripts/issue860.jl new file mode 100644 index 000000000..622e3c538 --- /dev/null +++ b/test/testscripts/issue860.jl @@ -0,0 +1,8 @@ +using Gadfly + +set_default_plot_size(7inch, 3inch) + +p1 = plot(x=[0], y=[0], Scale.x_discrete, Geom.histogram2d) +p2 = plot(x=[0], y=[0], Scale.y_discrete, Geom.histogram2d) + +hstack(p1, p2)