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

fix grouping of zero-height bar in barplot #3058

Merged
merged 11 commits into from
Oct 12, 2023

Conversation

ctarn
Copy link
Contributor

@ctarn ctarn commented Jul 11, 2023

fix #3055

@@ -110,7 +110,11 @@ function stack_grouped_from_to(i_stack, y, grp)
from = Array{Float64}(undef, length(y))
to = Array{Float64}(undef, length(y))

groupby = StructArray((; grp..., is_pos = y .> 0))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell just changing this to .>= works too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid not. Given two stacked bars of heights [-6, 0], the second bar would stacked on the first one as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. You do remind me that we should determine the is_pos only based other bars inside of the same group, instead of globally. I will append a commit later. Thanks.

Copy link
Contributor Author

@ctarn ctarn Aug 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delayed update. I have been too busy recently :(. A new commit has been added. You can test it using:

import Makie, CairoMakie

fig = Makie.Figure()

ax = Makie.Axis(fig[1, 1])
xs = [1, 1, 1, 1]
ys = [0, 1, -1, -1]
stack = [1, 2, 1, 2]
dodge = [1, 1, 2, 2]
color = Makie.cgrad(:Set2_8)[1:4]
Makie.barplot!(ax, xs, ys; stack, dodge, color, bar_labels=string.(ys))

display(fig)

@ctarn ctarn requested review from ffreyer August 26, 2023 09:16
@ffreyer
Copy link
Collaborator

ffreyer commented Aug 29, 2023

It would be good to extend the tests in https://github.com/MakieOrg/Makie.jl/blob/master/test/stack.jl to include cases that got fixed here. While you're at it you could also merge that with https://github.com/MakieOrg/Makie.jl/blob/master/test/barplot_labels.jl into a barplot.jl.

Also still needs a note in https://github.com/MakieOrg/Makie.jl/blob/master/NEWS.md on what this pr fixes.

@ctarn
Copy link
Contributor Author

ctarn commented Aug 31, 2023

ok. I will update it later.

@ctarn
Copy link
Contributor Author

ctarn commented Oct 7, 2023

Please let me know if any further modification is required. thanks

@ffreyer
Copy link
Collaborator

ffreyer commented Oct 7, 2023

Looks fine to me but I think @SimonDanisch or @jkrumbiegel should take another look at this since I don't know the barplot code that well.

@SimonDanisch
Copy link
Member

To be honest, I don't know the grouping code very well either.. I guess that has been @jkrumbiegel and @piever expertise ;)

@jkrumbiegel
Copy link
Member

Not my code either, but looks ok to me :)

@SimonDanisch SimonDanisch merged commit c9010c3 into MakieOrg:master Oct 12, 2023
13 checks passed
SimonDanisch added a commit that referenced this pull request Oct 12, 2023
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 this pull request may close these issues.

the label of a zero-height stacked bar is placed to the bottom by mistake
4 participants