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

make hist more flexible #1150

Merged
merged 5 commits into from
Aug 4, 2021
Merged

make hist more flexible #1150

merged 5 commits into from
Aug 4, 2021

Conversation

SimonDanisch
Copy link
Member

@SimonDanisch SimonDanisch commented Jul 20, 2021

With scale_to, offset, fillto and flip, one can put multiple histograms into the same plot:

fig = Figure()
ax = Axis(fig[1, 1])
for i in 1:5
     hist!(ax, randn(1000), scale_to=0.6, offset=i, fillto=i, direction=:x, flip=true)
end
fig

image

@SimonDanisch SimonDanisch requested a review from piever July 20, 2021 17:13
@SimonDanisch
Copy link
Member Author

@piever @jkrumbiegel do you have any concerns about this, or can we merge?

src/stats/hist.jl Outdated Show resolved Hide resolved
src/stats/hist.jl Show resolved Hide resolved
@piever
Copy link
Contributor

piever commented Jul 27, 2021

Nice! I've added a couple of comments, based on the observation that the API should try to respect as much as possible the proportionality between bar length and number of entries in bin.

@jkrumbiegel
Copy link
Member

We wanted to find a consistent "interface" for these flipping keywords. (Also because AlgebraOfGraphics should be able to use this information). We currently have direction and orientation, this would add flip.

@piever
Copy link
Contributor

piever commented Jul 30, 2021

We currently have direction and orientation, this would add flip.

IIUC, flip here is not x vs y, but rather "bars go towards the right vs left (or down vs up)". That being said, if we wanted to use flip for "flip x and y axis" in the future, this use here would conflict.

@SimonDanisch
Copy link
Member Author

Alright, I removed flip since one can just do that via scale_to=-x.
I also moved offset to the barplot recipe, and made it set fillto if fillto is automatic.
So now the example is a bit simpler:

fig = Figure()
ax = Axis(fig[1, 1])
for i in 1:5
     hist!(ax, randn(1000), scale_to=-0.6, offset=i, direction=:x)
end
fig

image

@piever
Copy link
Contributor

piever commented Aug 4, 2021

LGTM! I've just added a small comment to disable offset when stack is also given. We may want to implement offset + stack in the future, but that doesn't need to happen in this PR.

Co-authored-by: Pietro Vertechi <pietro.vertechi@neuro.fchampalimaud.org>
@SimonDanisch SimonDanisch merged commit e2b641a into master Aug 4, 2021
@SimonDanisch SimonDanisch deleted the sd/flexible-hist branch August 4, 2021 09:34
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.

None yet

3 participants