Difference that can lead to a wrong interpretation when using density and not bar graph

I'm trying to plot the relation between a nominal qualitative variable and a discrete quantitative variable. When I use bar graphs, the amount of Y and N values are consistent. But when I use a density plot, the proportion of Y and N values seems to change, making this plot misleading. Looking at the amount of N values in the bar graph between the score values ​​from 250 to 500, the amount is smaller compared to the same score range in the density graph. Why does it happen?Density plot

Bar plot

 ggplot(pib_date, aes(x = score, fill = first_payment_overdue, color = first_payment_overdue)) + scale_color_manual(values = c("Y" = "#060606", "N" = "#f5693f")) + scale_fill_manual(values = c("Y" = "#060606", "N" = "#f5693f")) + geom_density(alpha = 0.4) + labs(title = "Distribuição de score por fpo") + scale_x_continuous("Score", breaks = seq(0, 960, by = 100)) + theme_minimal()
7 Related questions 6 Comparing Kernel Density Estimation plots 0 R question about plotting probability/density histogram the right way 3 Difference between two density plots Related questions 6 Comparing Kernel Density Estimation plots 0 R question about plotting probability/density histogram the right way 3 Difference between two density plots 2 Interpreting Density Plot in R 2 Histogram and density in R 3 Issue with when plotting `density` objects 4 ggplot2, histogram: why do y = ..density.. and stat = "density" differ? 0 Histograms and Density Plots do not match up 0 Kernel Density Estimate (Probability Density Function) is wrong? 0 Data Visualization Clarification in R for a density / histogram plot Load 7 more related questions Show fewer related questions Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like