so I've been attempting to put my KDE function of my histogram and Ive managed to do so, however when i try to scale the sec.axis = sec_axis(~./#number) i cant seem to match it t my histogram is there a way i can make it automatically choose which number it should display to get the best match.
the code im using is
a <- ggplot(birds, aes(birds$`Log10(Total Average)`))+
geom_histogram(col = 'black', fill = 'white', binwidth = 0.2)+
labs(x = 'Log10 total body mass (kg)', y = 'Frequency', title = 'Average total body mass (kg) of bird species (male adn female) in KNP')
a + geom_density(aes(y=..count..), col=2, size=1)+
scale_y_continuous(sec.axis = sec_axis(~./40, name = "Density"))