如何增加ggplot2图例中点的大小? [英] How to increase the size of points in legend of ggplot2?

查看:2571
本文介绍了如何增加ggplot2图例中点的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个数字中有数千个点,并设置size = 1。但是图例中的磅值也减少了。如何增加图例中的磅值?

例如,

 <$ c $ (1)数据帧(x = seq(1,num),y = runif(num),z = rep(1) :2,each = num / 2))
df $ z < - factor(df $ z)
library(ggplot2)
p < - ggplot(df,aes(x,y ,color = z))+ geom_point(size = 1)
p

解决方案

在图中添加 + guides(color = guide_legend(override.aes = list(size = 10)))。你可以玩 size 参数。

I have thousands of points in one figure and set the "size = 1". However the point size in the legend is reduced too. How to increase the point size in the legend?

For example.

num <- 10000
set.seed(1)
df <- data.frame(x = seq(1, num), y = runif(num), z = rep(1:2, each = num / 2))
df$z <- factor(df$z)
library(ggplot2)
p <- ggplot(df, aes(x, y, colour = z)) + geom_point(size = 1)
p

解决方案

Add a + guides(colour = guide_legend(override.aes = list(size=10))) to the plot. You can play with the size argument.

这篇关于如何增加ggplot2图例中点的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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