-
Notifications
You must be signed in to change notification settings - Fork 2k
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
objects.Norm : Normailize among a group? #3663
Comments
I think the main operation here is supported (
so.Plot(df, x='year', color='category')
.add(so.Line(), so.Count(), so.Norm(func="sum", by=["x"]))
) But that's a little different than your manual example because your observations are incomplete and |
Awesome! Thanks for your reply! Yes, that does the desired effect. I agree that the For other reading this, I'll note that in this case adding a
Is there interest in adding a similar example to objects.Norm.html docs? There currently aren't any examples that use the
(this render has the legend positioned differently than the other examples on the objects.Norm.html page. I'm not sure what specifically generates that page, and why it looks different. I found this notebook, but it doesn't seem to do anything like that.) It's up to you whether it seems like a useful add or just makes the page too busy. Feel free to mark this issue as closed. Thanks again for your response, and for your fantastic work on Seaborn! |
You have indeed found the source for the examples that you're looking at. The seaborn docs build system is pretty complicated though. Demonstrating By the way — there's no need to put One other comment I would make is that you are sort of making a histogram here :) (
so.Plot(df, x='year', color='category')
.add(so.Line(), so.Hist(stat="proportion", common_norm=["x"]))
) |
Ok, thanks. I think I might not have a good enough grasp on how text between the code is created that would prevent me from making any PRs here. I'll leave it as-is then for now.
Thank you for noting. I was doing these plots in a script ran in pycharm rather than a notebook, so needed to get it it to actually render out.
This is a good point. I looked at the Ideas for improving so.Hist docsLooking at it again, I'll note that the example and docs for common_args is a bit confusing. My initial reading was that you should pass in dataframe columns like "island"/"sex"/etc as you typically do for plot args. This is not the case and until you realize what is going on, the "col" comes across as somewhat magic and disconnected from prior context. I would have a few suggestions to consider. Give an example within the param docstringCurrently """
@dataclass
class Hist(Stat):
...
common_norm : bool or list of variables
When not `False`, the normalization is applied across groups. Use
`True` to normalize across all groups, or pass variable name(s) that
define normalization groups.
+ For example, passing in ["x"] would normalize within each x value.
+ If you have a facet, passing in ["col"] would normalize within
+ the facet column.
""" Improve each example by adding a labelGenerally it might be useful to add labels to each example on the object.Hist example. p = p.facet("island")
(
p.add(so.Bars(), so.Hist(stat="proportion"))
.label(y="Proportion of all Penguins")
) ... (
p.add(so.Bars(), so.Hist(stat="proportion", common_norm=False))
.label(y="Proportion of all Penguins on the Island")
) This makes it clear what is changing between the output plots. Add a explanation of the use of "col"In the text of object.Hist # Current text before plot in the docs
- Or, with more than one grouping varible, specify a subset to normalize within:
# Proposal
+ It might be the case we have multiple grouping variables.
+ For example, we already are grouping on "island", which appears in the "col" of the facet.
+ If we also use the "color" variable to group by "sex", we can specify which variable to normalize on. (
p.add(so.Bars(), so.Hist(stat="proportion", common_norm=["col"]), color="sex")
.label(y="Proportion of all Penguins on the Island")
) Consider whether want an example with
|
The problem
I am trying to achieve an effect where the values within a group is normalized. Consider
With the current interface we can create something like
However, I actually want something like
Question
As far as I can tell there isn't a way to create this style of plot. Am I missing something in
so.Norm
that enables this (I found the documentation ofso.Norm
arguments somewhat confusing)? There may also be some other kind of functionality/plot already in Seaborn to enable this kind of analysis without usingso.Norm
?Otherwise, is there interest in adding something like a
within_groups
arg (or other name. Not sure what makes the most sense.) toso.Norm
to enable this?The text was updated successfully, but these errors were encountered: