- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经阅读了以下文章:
https://trinkerrstuff.wordpress.com/2018/03/15/2246/
现在我正在尝试使用建议的方法 bquote
在我的情节中。但是我无法让它工作。我有以下代码
x <- seq(0, 2*pi, 0.01)
y <- sin(x)
y_median <- median(y)
ggplot(mapping = aes(x = x, y = y)) +
geom_line() +
geom_label(aes(label = bquote("median" ~ y==~.y_median), x = 1, y = y_median))
Error in as.data.frame.default(x[[i]], optional = TRUE) :
cannot coerce class ‘"formula"’ to a data.frame
最佳答案
ggplot(mapping = aes(x = x, y = y)) +
geom_line() +
geom_label(aes(label = list(bquote("median" ~ y==~.(y_median))),
x = 1, y = y_median),
parse=TRUE)
"median" ~ y==~.(y_median)
中缺少的括号.这在
?bquote
中讨论帮助页面:
‘bquote’ quotes its argument except that terms wrapped in ‘.()’ are evaluated in the specified ‘where’ environment.
bquote
在列表中,因为
aes
需要一个向量或一个列表。
geom_label
通过将相应的参数设置为 TRUE 来解析表达式。
关于r - 如何将 bquote 与 ggplot2 geom_label 结合使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51991695/
我想在 geom_label 中绘制一个上标的星星来自数据框字符串,但找不到解决方案。 一个最小的工作示例是 library(ggplot2) df <- data.frame(x = 1, y =
问题 我试图在不明显延伸 x 轴的情况下垂直对齐折线图上的 geom_label。有没有一种方法可以在图表右侧留出空白,以便 ggrepel 函数(下方)有工作空间? 我正在尝试复制 this 上的最
有没有办法格式化 geom_label 打印的日期?在 ggplot2超出它们的原始值(value)?在下面的示例中,日期打印为“1910-01-01”。但是,假设我只想打印月份和日期,并将月份作为文
由于某些原因,当您使用 geom_label 时,ggplot 会向实际点添加边框,但不会在图例中包含边框。一个简单的例子: library(tidyverse) mtcars %>% rowna
在构建我的 Shiny 应用程序时,我遇到了 ggplot2 图形在不同窗口大小下看起来非常不同的情况。第一张图以完整的桌面大小显示了情节——一切都很好: 但是,当我更改输出窗口的大小时,每个元素似乎
由于某些原因,当您使用 geom_label 时,ggplot 会向实际点添加边框,但不会在图例中包含边框。一个简单的例子: library(tidyverse) mtcars %>% rowna
当尝试将 geom_label() 框的左上角与 ggplot2 的 (0,10) 坐标对齐时,文本不再居中(见图)。是否可以有一个左上对齐的框,里面的文本居中? library(ggplot2) d
我的数据: dat % as.numeric()))) 但是,当我将这个表达式与 ggplot 一起使用时: ggplot() + geom_point(data = dat, aes(x = x
我在关注 this ggplot2 docs尝试使用 geom_label 重现文本标签.但我收到一条错误消息, "could not find function geom_label" . ?geo
在 R 中为我的 (gg) 图使用 geom_label 时,我注意到文本上方的空间比下方的空间大。如何将文本对齐到标签框的中间? x <- data.frame(x = c("Being not",
我已经阅读了以下文章: https://trinkerrstuff.wordpress.com/2018/03/15/2246/ 现在我正在尝试使用建议的方法 bquote在我的情节中。但是我无法让它
我想做的是,向使用 geom_point 制作的点添加标签,这些点具有映射到大小的变量。该值也显示在标签中。文本或标签应位于 geom_point 的正下方,但使用position_nudge 似乎不
我想做的是,向使用 geom_point 制作的点添加标签,这些点具有映射到大小的变量。该值也显示在标签中。文本或标签应位于 geom_point 的正下方,但使用position_nudge 似乎不
我想创建一个直方图,其中有一条垂直线表示平均值,并在该线上附加一个标签,给出平均值的精确值。 我可以轻松创建带有垂直线的基本直方图。 # needed library library(ggplot2)
我想在 geom_label 中使用“尺寸”作为美学.我的问题是最小标签尺寸太小以至于相应的标签几乎无法阅读。 在使用尺寸美学时,有没有办法设置“最小尺寸”之类的东西?如果有办法,它也应该可以指定最大
我是一名优秀的程序员,十分优秀!