Entering edit mode
6.2 years ago
Zee_S
▴
60
I would like to know a script template to do the above. can someone please help me?
I would like to know a script template to do the above. can someone please help me?
geom_smooth()
should suit your demand :
https://ggplot2.tidyverse.org/reference/geom_smooth.html
for the color : scale_color_manual(
) can be a start
But you should provide us with more information. What did you already try ?
Indeed, for a linear regression model, you can plot real versus the model-predicted values and plot the linear fit line via geom_smooth()
If you want to know how to do all of this, then take a look at RTrainingLect3.pptx, here: https://github.com/kevinblighe/Rtutorials
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Please show us you've invested some effort on your own trying to solve this. You seem to know the terms/jargon, have you tried googling? How far did you get?
hello!
thank you so much for your comments. Im sorry for not being more elaborate.
geom_smooth()
doesn't work for me with smoothScatter function. perhaps I'm not adding it at the right layer?I would also like to change the bandwidth for smoothing, to get less blurred data points at the peripheries. Can you please tell me how to do this? At the moment, with default bandwidth, my plot is oversmoothed.
I post here a template of the code i wrote for my plot:
Thank you so much for your help!
Please use
Add comment
or put this comment in your question instead of using the answer field for this. Also, please reformat this comment by marking code with the code buttom in the formating bar (10101
). By the way,doesnt work for me
, is most uninformative. Please elaborate.Thanks ATpoint. Zee_S, why use smoothScatter? - it uses base graphics. The solution that both Nicolas and I mentioned requires ggplot2.
To put a linear regression fit on a smoothScatter plot, you can just do this:
--------------------------------------------------
You may also be interested in 'hexagonal binning': A: Scatterplot with hexbin