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

BUG: BarPlot overlapping bars #277

Closed
KingBoomie opened this issue Sep 14, 2021 · 2 comments · Fixed by #323
Closed

BUG: BarPlot overlapping bars #277

KingBoomie opened this issue Sep 14, 2021 · 2 comments · Fixed by #323

Comments

@KingBoomie
Copy link

Here's what the bug looks like:
Visual bug

here's a minimum runnable file that reproduces the issue:

Click to expand repro!
using Markdown
using InteractiveUtils

using CairoMakie
using DataFrames
using AlgebraOfGraphics

data_fail = [["health", "health", "kids", "health", "religion", "other", "health", "religion"],["TARTU", "SA HIL", "SOS LAST", "TALLI", "EEKB", "PER", "EEST", "LIIT"],[1.5827569599999974e6, 1.4686506099999996e6, 1.449934999999999e6, 771253.4800000001, 451491.5399999999, 381715.32999999996, 316052.22, 296273.13]]

fail = DataFrame(cat=data_fail[1], name=data_fail[2], value=data_fail[3])

let plt = data(fail) * mapping(
		:name, 
		:value,
		color=:cat
		) * visual(BarPlot)
	draw(plt)
end

not_fail = fail[1:7,:]

let plt = data(not_fail) * mapping(
		:name, 
		:value,
		color=:cat
		) * visual(BarPlot)
	draw(plt)
end

Click to expand project toml!
[deps]
AlgebraOfGraphics = "cbdf2221-f076-402e-a563-3d30da359d67"
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"

[compat]
AlgebraOfGraphics = "~0.5.3"
CairoMakie = "~0.6.5"
DataFrames = "~1.2.2"
Click to expand julia versioninfo
julia> versioninfo()
Julia Version 1.6.0
Commit f9720dc2eb (2021-03-24 12:55 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: AMD Ryzen 9 3900X 12-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, znver2)

Note that the bug exists when there are 8 or more bars to display. It works as intended with 1:7 bars. (Tested upto 200). Also note that which bars are too wide changes with the number of bars (but not the order, aka not when adding a sorter to the mapping). But it's not on every change. (It changes on 8, 10, 12, 15, 29, 30)

@piever
Copy link
Collaborator

piever commented Sep 14, 2021

Thanks for the fully reproducible example!

This needs some small changes in Makie to work well out of the box (see MakieOrg/Makie.jl#1223). The problem is with the automatic width computation. Passing width = 0.8, ie visual(BarPlot) becomes visual(BarPlot, width=0.8), should fix it.

I'm leaving this open until it starts working out of the box.

@KingBoomie
Copy link
Author

Thanks for the quick answer and workaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants