Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
458 views
in Technique[技术] by (71.8m points)

r - How can I change my plot that it doesn't look that filled?

I would like to have a not that filled plot.

enter image description here

that is my code

ggplot(master, aes(x = Income, y = BMI, group = BMI, color = weight_class)) + 
  geom_line() + geom_point()+labs(title = "Correaltion between Income and BMI")+ scale_y_log10()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I'm not exactly sure what you mean by "not that filled"? Here are a few options:

You could change the alpha parameter to make the points more transparent with something like alpha=.25.

ggplot(master, aes(x = Income, y = BMI, group = BMI, color = weight_class)) + 
  geom_line(alpha=.25) + 
  geom_point(alpha=.25)+
  labs(title = "Correaltion between Income and BMI")+ 
  scale_y_log10()

You could change the plotting symbols to open rather than filled in circles with shape=1.

ggplot(master, aes(x = Income, y = BMI, group = BMI, color = weight_class)) + 
  geom_line() + 
  geom_point(shape=1)+
  labs(title = "Correaltion between Income and BMI")+ 
  scale_y_log10()

You could also randomly sample a fraction of the observations in each group - the code below samples 10% from each group:

master %>% 
group_by(weight_class) %>%
sample_frac(.1) %>% 
ggplot(aes(x = Income, y = BMI, group = BMI, color = weight_class)) + 
  geom_line() + 
  geom_point()+
  labs(title = "Correaltion between Income and BMI")+ 
  scale_y_log10()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...