user3206440
user3206440

Reputation: 5049

removing points while keeping the line in a scatter plot

How do I remove the points from a scatter plot created by below code ? I just wanted to keep the smoothed line.

ggplot(mtcars, aes(x=wt, y=mpg, color=cyl, shape=cyl)) +
  geom_point() + 
  geom_smooth(method=lm)

Upvotes: 0

Views: 5119

Answers (1)

Calum You
Calum You

Reputation: 15072

Take out geom_point, it's what's generating the points.

library(ggplot2)
ggplot(mtcars, aes(x = wt, y = mpg, color = cyl)) +
  geom_smooth(method = lm)

Created on 2018-04-26 by the reprex package (v0.2.0).

Upvotes: 4

Related Questions