楼主: jpld
24748 9

[学习分享] 画图神器ggplot2之二:修改图例guide_legend [推广有奖]

  • 2关注
  • 50粉丝

已卖:4份资源

讲师

2%

还不是VIP/贵宾

-

威望
0
论坛币
1264 个
通用积分
9.5333
学术水平
120 点
热心指数
120 点
信用等级
99 点
经验
1249 点
帖子
192
精华
0
在线时间
271 小时
注册时间
2009-5-29
最后登录
2024-6-25

楼主
jpld 发表于 2015-10-11 21:20:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
guide_legend(title = waiver(), title.position = NULL, title.theme = NULL, title.hjust = NULL,   title.vjust = NULL, label = TRUE, label.position = NULL, label.theme = NULL,       label.hjust = NULL, label.vjust = NULL, keywidth = NULL, keyheight = NULL, direction = NULL,       default.unit = "line", override.aes = list(), nrow = NULL, ncol = NULL, byrow = FALSE,       reverse = FALSE, order = 0, ...)Examples

library(reshape2) # for meltdf <- melt(outer(1:4, 1:4), varnames = c("X1", "X2"))p1 <- ggplot(df, aes(X1, X2)) + geom_tile(aes(fill = value))p2 <- p1 + geom_point(aes(size = value))# Basic formp1 + scale_fill_continuous(guide = "legend")

p1 + scale_fill_continuous(guide = guide_legend())

# Guide titlep1 + scale_fill_continuous(guide = guide_legend(title = "V")) # title text

p1 + scale_fill_continuous(name = "V") # same

p1 + scale_fill_continuous(guide = guide_legend(title = NULL)) # no title

# Control styles# key sizep1 + guides(fill = guide_legend(keywidth = 3, keyheight = 1))

# title positionp1 + guides(fill = guide_legend(title = "LEFT", title.position = "left"))

# title text styles via element_textp1 + guides(fill = guide_legend(  title.theme = element_text(size=15, face="italic", colour = "red", angle = 45)))

# label positionp1 + guides(fill = guide_legend(label.position = "bottom"))

# label stylesp1 + scale_fill_continuous(breaks = c(5, 10, 15),  labels = paste("long", c(5, 10, 15)),  guide = guide_legend(direction = "horizontal", title.position = "top",    label.position="bottom", label.hjust = 0.5, label.vjust = 0.5,    label.theme = element_text(angle = 90)))

# Set aesthetic of legend key# very low alpha value make it difficult to see legend keyp3 <- qplot(carat, price, data = diamonds, colour = color,  alpha = I(1/100))p3

# override.aes overwrites the alphap3 + guides(colour = guide_legend(override.aes = list(alpha = 1)))

# multiple row/col legendsp <- qplot(1:20, 1:20, colour = letters[1:20])p + guides(col = guide_legend(nrow = 8))

p + guides(col = guide_legend(ncol = 8))

p + guides(col = guide_legend(nrow = 8, byrow = TRUE))

p + guides(col = guide_legend(ncol = 8, byrow = TRUE))

# reversed order legendp + guides(col = guide_legend(reverse = TRUE))


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:ggplot2 Legend Guide gplot plot direction title

沙发
新手请多关照 发表于 2015-10-11 21:47:16
我还以为是PS呢
0532qdfpw.jimdo.com,0531jnfpw.jimdo.com,0512szfpw.jimdo.com,025njfpw.jimdo.com,0571hzfpw.jimdo.com,0574nbfpw.jimdo.com,0551hffpw.jimdo.com,0755szfpw.jimdo.com,020gzfpw.jimdo.com,0591fzfpw.jimdo.com,0592xmfpw.jimdo.com,O771nnfpw.jimdo.com,0898hkfpw.jimdo.com,0371zzfpw.jimdo.com,027whfpw.jimdo.com,0574nbfp.jimdo.com,whfp5188.jimdo.com,0574nbfpw.jimdo.com0731csfpw.jimdo.com,0791ncfpw.jimdo.com,024syfpw.jimdo.com,0411dlfpw.jimdo.com,0451hebfpw.jimdo.com,O431ccfpw.jimdo.com,028cdfpw.jimdo.com,0871kmfpw.jimdo.com,0851gyfpw.jimdo.com,0891lsfpw.jimdo.com,0311sjzfpw.jimdo.com,0351tyfpw.jimdo.com029xafpw.jimdo.com,0931lzfpw.jimdo.com,0951ycfpw.jimdo.com,0971xnfpw.jimdo.com,029xafpw.jimdo.com,0931lzfpw.jimdo.com,0951ycfpw.jimdo.com,0971xnfpw.jimdo.com,010bjfpw.jimdo.com,021shfpw.jimdo.com,022tjfpw.jimdo.com,023cqfpw.jimdo.com,0771nnfpw.jimdo.com,hnfp123.jimdo.com,guiyangkfp123.jimdo.com,nanchangdkfp6688.jimdo.com,0574nbfp.jimdo.com,029xafp.jimdo.com,whdkfp123.jimdo.com,hffp000.jimdo.com,jnfp5188.jimdo.com,whfp5188.jimdo.comwuhudkfp6688.jimdo.com

藤椅
蓝色 发表于 2015-10-11 23:37:10

板凳
yuyike 发表于 2015-10-12 07:10:11 来自手机
不错不错

报纸
dark293 发表于 2016-3-10 16:30:14
您好,我们可以注意到,随着图例大小的改变或移除,绘制数据的区域也随之变化。
请问如何设置图形尺寸,以保证绘图区大小保持不变呢?谢谢!

地板
Ariel1991 发表于 2018-5-11 21:11:54
蓝色 发表于 2015-10-11 23:37
http://docs.ggplot2.org/current/guide_legend.html

http://docs.ggplot2.org/current/
这两个网页都打不开了?

7
yangming98 发表于 2018-5-12 22:29:46 来自手机
jpld 发表于 2015-10-11 21:20
guide_legend(title = waiver(), title.position = NULL, title.theme = NULL, title.hjust = NULL,   titl ...
好的好的好的好的好的好的

8
yangwj8 发表于 2019-1-4 11:17:31
图片呢

9
GAILY2014 发表于 2019-1-4 11:23:09 来自手机
马一下

10
tianwk 发表于 2019-1-6 16:17:12
Thanks for sharing

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-9 05:20