- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在像这样使用 ggplot2 绘制线条:
ggplot(iris, aes(Petal.Width,Petal.Length,color=Species)) + geom_line() + theme_bw()
.
我发现图例标记很小,所以我希望它们更大。如果我改变大小,绘图上的线条也会改变:
ggplot(iris, aes(Petal.Width,Petal.Length,color=Species)) + geom_line(size=4) + theme_bw()
.
但我只想在图例中看到粗线条,我希望情节上的线条很细。我尝试使用 legend.key.size
但它改变了标记的平方,而不是线的宽度:
library(grid) # for unit
ggplot(iris,aes(Petal.Width,Petal.Length,color=Species))+geom_line()+theme_bw() + theme(legend.key.size=unit(1,"cm"))
我也试过用积分:
ggplot(iris,aes(Petal.Width,Petal.Length,color=Species)) + geom_line() + geom_point(size=4) + theme_bw()
但当然它仍然会影响情节和图例:
我想用线条来绘制情节,用点/点来绘制图例。
所以我想问两件事:
最佳答案
要仅在图例中更改线宽,您应该使用函数 guides()
然后对于 colour=
使用 guide_legend()
和 override.aes=
并设置 size=
。这将覆盖绘图中使用的大小,并将仅针对图例使用新的大小值。
ggplot(iris,aes(Petal.Width,Petal.Length,color=Species))+geom_line()+theme_bw()+
guides(colour = guide_legend(override.aes = list(size=3)))
要获取图例中的点和绘图中的线,解决方法是添加 geom_point(size=0)
以确保点不可见,然后在 guides()
中设置 linetype=0
删除线和 size=3
以获得更大的点。
ggplot(iris,aes(Petal.Width,Petal.Length,color=Species))+geom_line()+theme_bw()+
geom_point(size=0)+
guides(colour = guide_legend(override.aes = list(size=3,linetype=0)))
关于r - 在不影响情节的情况下控制ggplot2图异常(exception)观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35500993/
感谢 Stackoverflow 的工作人员,我已经让下面的脚本运行良好。它基本上删除了除了 A 列中的值与脚本中的值列表匹配的行之外的所有行。 但是,我想在大约 400 条记录上运行该脚本。当我将下
我正在像这样使用 ggplot2 绘制线条: ggplot(iris, aes(Petal.Width,Petal.Length,color=Species)) + geom_line() + the
我觉得我在这里缺少一些非常基本的东西...... 我正在尝试合并 Stata 中的两个数据集,FranceSQ.dta 和 FranceHQ.dta。它们都有一个我创建的名为“uid”的变量,用于唯一
我编写了一段代码,用于从文本文件的列中读取值。为了输出值的数量,我使用了“长度”,效果很好......但我只需要计算唯一值的数量。 public class REading_Two_Files { p
我是 Python 新手,因此我的问题看起来非常愚蠢。我尝试制作一些制作二维数组的程序。一个函数将项目放入列表并返回一个数组。然后,第二个函数将第一个函数的结果放入外部列表中。我的程序如下所示: de
给定一个字典: data = {'18': [3.89, 1.28], '20': [1.39, 3.15], '15': [1.42, 3.10]} 我想挑选出与其他内容明显不同的项目,如 18 中
这个问题不太可能对任何 future 的访客有帮助;它只与一个较小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于全世界的互联网受众。如需帮助使此问题更广泛适用,visit the
我有一个应用程序,我希望在某些网络后端修改配置。 我最初的想法是将默认值存储在 plist 文件中,然后通过 JSON 从远程服务器请求更新值。我不喜欢这个,因为它是异步的,所以即使用户终止应用程序并
问题围绕康威的生命游戏以及如何为新一代同时执行所有规则。游戏遵循新世代的三个规则,即:恰好有三个活邻居的死细胞变为活细胞,恰好有一个活邻居的活细胞变为死细胞,具有三个以上活邻居的活细胞变为死细胞。原始
似乎没有内部联接,它会给我不同的值,但有了它,它就会显示所有这些值。为什么它没有给我独特的值(value)观? 她是我的代码: SELECT DISTINCT m.manager_accou
有人可以帮助我理解为什么我没有得到预期的输出吗?我有以下代码。 var targetArray = []; var tempVar = {}; var json = [ { id:1, ava
我正在 Matlab 上编写一个 OOP,一个用于分离电子邮件的朴素贝叶斯。像这样 classdef NaiveClass %NaiveClass what this will do is hold
我想在我的协议(protocol)和工厂中访问相同的值,因此我使用以下代码进行了测试: import time from multiprocessing import Process from twi
我有一个数据框,其中有一个“裤子”列,其中包含许多不同类型的裤子。大多数裤子都会从其类型开始。例如:Jeans- Replay-blue,或 Chino- Uniqlo-~,或者 Smart-Next
我对 Sprague–Grundy 定理感到困惑,该定理在 CodeChef 上尝试解决公平游戏时被用在许多问题中。它只是指出,公正的游戏等同于 nimber 或 grundy 值。游戏的结果取决于所
考虑这个程序: #include union myUnion { int x; long double y; }; int main() { union myUnion a;
我正在尝试构建一个查询来选择唯一的值组。我知道如何对值进行分组并选择不同的值,但我不知道如何选择不同的值组而不考虑所考虑元素的顺序。更准确地说: 我的 XML 是这样的: value1
我需要使用后端提供的链接下载文件。要下载文件,使用返回 Progress() 对象的异步 API。问题是 FlatMap 无法从 Publisher 映射至 Publisher .我要解决的另一个问题
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 7 年前。 Improve this ques
我了解 JWT 是安全的。但只是想知道一些我无法理解的概念。 假设身份验证服务器“A”将签名的 token 发送到应用程序服务器。如果我没记错的话签名是由服务器“A”上的私钥完成的。现在应用程序服务器
我是一名优秀的程序员,十分优秀!