如何在图例中更改符号而不更改图中的符号 [英] How to change symbol in legend without changing it in the plot

查看:73
本文介绍了如何在图例中更改符号而不更改图中的符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试复制以下情节: 要复制的图

I'm trying to replicate the following plot: Plot to replicate

我已经了解到了以下内容:我的情节

I have gotten as far as this: My plot

因此,剩下要做的就是将图例中的符号更改为大圆形圆圈,而不是带有穿过它们的直线的小圆圈.如何在不扩大情节范围的情况下实现这一目标?

Hence, the only thing left to do is change the symbols in the legend to big round circles instead of small circles with a line going through them. How can I achieve this without making the circles in my plot bigger?

到目前为止,我已使用以下代码创建绘图:

I used the following code to create my plot so far:

g <- ggplot(d, aes(x = Num.3.Syllable.Words / Num.Words,
                   y = Num.Words / Num.Sentences, colour = Educational.Level)) 

g +
  geom_point() + geom_smooth(method = "lm", se = FALSE) +
  facet_grid(Educational.Level ~ .) +
  scale_x_continuous(breaks = c(0.05, 0.15, 0.25), labels = scales::percent) +
  scale_y_continuous(breaks = c(10, 20)) +
  labs(x = "Share of words with 3+ syllables", 
       y = "Words per sentence",
       colour = "Educational level", 
       title = "Ad Copy Complexity in Magazines", 
       subtitle = "Arranged by Typical Readership")

我要添加什么?我可以使用指南功能吗?提前致谢.

What do I add? Do I use the guides function? Thanks in advance.

推荐答案

您可以通过覆盖此类指南来实现此目的...

You can do this by overwriting the guides like this...

ggplot(mtcars, aes(hp, mpg, group=gear, color=as.factor(gear))) + 
  geom_point() + 
  geom_line() + 
  guides(color = guide_legend(override.aes = list(linetype = 0, size=5)))

这篇关于如何在图例中更改符号而不更改图中的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆