Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattriks committed Nov 18, 2019
1 parent 4fa41cd commit 296fb19
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/guide.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function render_discrete_color_key(colors::Vector{C},
colrows = Array{Int}(undef, numcols)
m = n
for i in 1:numcols
colrows[i] = min(m, ceil(Integer, (n / numcols)))
colrows[i] = ceil(Int, m/(1+numcols-i))
m -= colrows[i]
end

Expand Down
2 changes: 1 addition & 1 deletion src/guide/keys.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function render_discrete_key(labels::Vector{String}, title_ctx::Context, title_w
colrows = Array{Int}(undef, numcols)
m = n
for i in 1:numcols
colrows[i] = min(m, ceil(Integer, (n / numcols)))
colrows[i] = ceil(Int, m/(1+numcols-i))
m -= colrows[i]
end

Expand Down
15 changes: 15 additions & 0 deletions test/testscripts/key_columns.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

using Gadfly

set_default_plot_size(14cm, 8cm)

# Issue #1344

datas = Gadfly.Data(color= ["D", "A", "C", "D", "A", "C", "D", "D", "A", "B"],
shape=["E", "F", "F", "E", "G", "E", "E", "G", "H"])
scales = [Scale.color_discrete(levels=["A","B","C","D"]), Scale.shape_discrete(levels=["E","F","G","H"]) ]
aes = Scale.apply_scales(scales, datas)
theme1 = Theme(key_max_columns=4)
guides = [render(g, theme1, aes[1])[1].ctxs for g in (Guide.colorkey(), Guide.shapekey())]

gridstack([guides[i][j] for i in 1:2, j in 1:4])

0 comments on commit 296fb19

Please sign in to comment.