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

Stat.histogram2d update #1237

Merged
merged 1 commit into from
Jan 5, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/bincount.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions src/statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions test/testscripts/issue860.jl
Original file line number Diff line number Diff line change
@@ -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)