-
Notifications
You must be signed in to change notification settings - Fork 51
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
Is there an out-of-the-box way to do a faceted histogram with percentages instead of counts? #1155
Comments
Hello! To make a histogram display density instead of counts: + geom_histogram(aes(y='..density..')) To format it as a percentage: + scale_y_continuous(format=".0%") Could you please clarify what do you mean by "faceted histogram"? |
Thanks for your response, @ASmirnov-HORIS . |
Sorry if I confused you, but Nevertheless, here is a code on Lets-Plot, based on your demo: import pandas as pd
from lets_plot import *
LetsPlot.setup_html()
df = pd.read_csv("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/penguins.csv")
ggplot(df, aes(x="flipper_length_mm")) + \
geom_histogram(aes(y='..density..'), binwidth=3, center=1) + \
scale_y_continuous(format=".0%") + \
facet_grid(x="species", y="sex", y_order=-1) |
Thanks for the clarification and example @ASmirnov-HORIS . |
I see. |
For each facet group, i'm looking for a histogram of the counts within the group divided by the total count within the group, expressed as a percentage. |
Hi @araichev , we've just added UPD: v4.4.1 |
Without having to create the percentages in your dataframe ahead of time?
Seems possible in ggplot: https://forum.posit.co/t/trouble-scaling-y-axis-to-percentages-from-counts/42999/3 .
The text was updated successfully, but these errors were encountered: