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?
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