Data Science Desktop Survival Guide
by Graham Williams |
|||||
Scatter Plot with Same Smooth Fitted Curve |
20180603
## `geom_smooth()` using formula 'y ~ x'
|
set.seed(26439)
ds %>% sample_n(100) %>% ggplot(aes(x=min_temp, y=max_temp)) + geom_point() + stat_smooth(method="loess")
The rather jagged line from point to point does not give a very convincing picture of any relationship between the two variables. A common approach is to introduce a statistical function to “fit” a single smoother line to the points. We aim to draw a smoother line from left to right the follows the points but without the requirement of going through every point. The resulting plot here uses ggplot2::geom_smooth() with a so called locally weighted scatterplot smoothing method or LOESS to produce the smoothed line. As a result we can observe statistically something of a relationship between the two variables although it is not a simple relationship.
|