Presently, I am trying to get a 2 dimensional map for Chicago crimes, and am using sort of heat map feature. We are using longitude and latitude on x and y axis respectively.
I am trying to understand the role of the
bins feature in
stat_density2d function. From the regular concept of histogram in one dimension, larger number of bins means we get kinda skinny bars, holding lesser numbers of values in each bar.
But, now that we are working on 2 dimensional histogram, I am having difficulty in grasping the concept. To this end, I implemented my same code with two different values for the
bins feature. Here is my original code;
gg <- ggplot(data=crime_2003%>% filter(Location.Description=="STREET"), aes(x=Longitude, y=Latitude)) + #geom_point(colour='red')+ stat_density2d(aes(fill=..level..), geom="polygon",bins=12)+ scale_fill_gradient(low="skyblue2", high="firebrick1", name="Distribution")+ labs(title="Distribution of Street Related Crimes in Chicago in 2003", subtitle="Western Chicago seems to have majority of Street Related Crimes in 2003", caption="Source: Chicago City") gg
bins=12 and I obtain the following plot, labelled,
bins_12. Then I changed number of
bins to 5 and I got the plot,
bins_5. It seems bins=12 has less number of breaks. Can I kindly get some advice on how to interpret this difference?thanks