Home > other >  R language pack ggplot drawing, how to add different methods fitting the trend line of the illustrat
R language pack ggplot drawing, how to add different methods fitting the trend line of the illustrat

Time:09-20

Ggplot drawing, the code is as follows, respectively with four methods fitting the trend line, the four trend line illustration of how to add?
Each trend line should be at the same time with color, line width, linear three elements, said
Ask everybody to give directions,
 ggplot (mtcars, aes (MPG, wt)) + 
Geom_point () +
Geom_smooth (method='lm, se=FALSE, show the legend=TRUE,
='black' linetype=1, color, size=1) +
Geom_smooth (formula=y ~ poly real (x, 2), se=FALSE, show the legend=TRUE,
Linetype=2, color='blue', size=1.2) +
Geom_smooth (method='gam, se=FALSE, show the legend=TRUE,
='gold' linetype=3, color, size=1.5) +
Stat_function (fun=function (x) 0.08 * x + 5, linetype=4,
Show. Legend=TRUE, size=2 color='red')
  • Related