Hi everybody,
I want to plot the data and added a smooth curve (LS line for example) but the smooth curve does not show up when the text option is added to aes() (Eventually I want to use ggplotly and need to add additional information to the tooltip, hence the text option). Could somebody help me sort out the problem? I am using Windows 10, R 4.0, R-Studio 1.3.957, ggplot2 3.3.0. Thanks.
library(ggplot2)
library(plotly)
#>
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#>
#> last_plot
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following object is masked from 'package:graphics':
#>
#> layout
library(tibble)
df = tibble(Sample = letters[1:5], GMT=c(8,14,18,21,22), RSD=c(47,6,29,36,30))
tmpplot1=ggplot(df, aes(x=GMT, y=RSD))+
geom_smooth(method='lm') +
geom_point()
tmpplot2=ggplot(df, aes(x=GMT, y=RSD, text=paste('Sample:', Sample)))+
geom_smooth(method='lm') +
geom_point()
tmpplot1
#> `geom_smooth()` using formula 'y ~ x'
tmpplot2
#> `geom_smooth()` using formula 'y ~ x'
Created on 2020-06-04 by the reprex package (v0.3.0)