Problem context: Scatter plot; Using ggplot2 with data from data frame; seeking to add a custom geom-line() [or geom_abline()] to include inside scatter plot confidence interval upper and lower bands on discrete data using linear regression model.
Error context: Message Error: Discrete value supplied to continuous scale
Yes, I know and understand that the data is discrete. Which is recommended for adding line to numeric data for show lines that permit fitted custom lines locations? Similar to what cars::scatterplot() does with quartiles line positions displayed, but I seek to add custom confidence interval upper and lower bands. For ggplot2 which is recommended: geom_line() or geom_segment() or geom_abline()?
ggplot(nt, aes(x=hr, y=temp)) + geom_point(aes(color=temp), size=3) +
scale_color_gradientn(colors = c("#00AFBB", "#E7B800", "#FC4E97")) +
geom_line(data=nt, aes(x = hr, y = temp, color = 'black'))
sample data: for data frame 'nt' (correction: nt, normtemp, same names)
temp
<dbl>
hr
<int>
1 96.3 70
2 96.7 71
3 96.9 74
4 97.0 80
5 97.1 73
6 97.1 75