r - 如何减少ggplot2中的图例框宽度
问题描述
我的代码
ggplot() +
geom_polygon(data =russia, aes(long, lat, group = group), fill = "grey")+
geom_point(data = prisons, aes(x=lon, y = lat, color=type))+
theme(legend.justification=c(1,0), legend.position=c(1,0),
legend.box.background = element_rect(color="red",size=1),
legend.key.size = unit(0.2, "cm"))
这个怎么做?
解决方案
尝试使用legend.margin
参数。
theme(legend.margin=margin(0,0,0,0))
边距让您分别指定上边距、右边距、下边距和左边距。
推荐阅读
- go - 如何防止sync.Pool创建两个实例
- javascript - 如何使用 javascript 在 Sharepoint 中获取列表的文件夹名称?
- docker - 如何让 nginx 停止使用 service_name 进行重定向?
- python - 如何为字典中的每个输入项创建一个列表 - Python?
- selenium - 例外:过时的元素引用:元素未附加到页面文档
- python - 小 Python ord() 脚本
- javascript - 如何汇总价格表中的值?
- ssl - Nginx 反向代理相同的 server_name 不同的位置与 SSL
- javascript - 在将数据推入数组时,不按顺序添加
- python - 将列表输入转换为字符串输出