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

feat: added colors parameter to allow user to select the colour of ea… #447

Closed
wants to merge 2 commits into from

Conversation

jjhw3
Copy link
Contributor

@jjhw3 jjhw3 commented Oct 3, 2023

Added a 'colors' parameter to histplot to allow users to set histogram colours in the same way as the labels. Before this change, one could not pass one color per histogram without histplot crashing, as all the colors were being passed into ax.stairs as a _kwargs entry.

@jjhw3 jjhw3 closed this Oct 3, 2023
@andrzejnovak
Copy link
Member

Hey @jjhw3 welcome. Could you describe the issue a bit more? I seem to easily be able to write

hs = [hist.new.Reg(10,0,10).Weight().fill(np.random.normal(3+i, 1, 1000)) for i in range(3)]
hep.histplot(hs, histtype='fill', stack=True, color=['red', 'blue', 'firebrick']);

to get the following
image

@jjhw3
Copy link
Contributor Author

jjhw3 commented Oct 3, 2023

Hey @jjhw3 welcome. Could you describe the issue a bit more? I seem to easily be able to write

hs = [hist.new.Reg(10,0,10).Weight().fill(np.random.normal(3+i, 1, 1000)) for i in range(3)]
hep.histplot(hs, histtype='fill', stack=True, color=['red', 'blue', 'firebrick']);

to get the following image

Hey @andrzejnovak, just after creating the PR, I realised that there was an intended way to do this which was simply had unintended behaviour. While your example works, if you change the color list to a tuple of colors, it would fail. This confused me for quite a while but the fix in this PR is not the right way to do it. Please see my new PR here #448 .

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.

2 participants