- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 ggplot2 的新手,一直在尝试找到一个全面的美学列表。我想我理解它们的目的,但很难知道哪些可以在各种情况下使用(主要是几何图形?)。 Hadley 的网站偶尔会在各个几何图形的页面上列出可用的美学,R 文档偶尔(尽管更罕见)也会这样做。我什至发现了一个两者不太匹配的几何对象。
我通过这里的评论寻找答案,甚至买了这本书!唉,没有帮助。
我认为如果有一张表格,其中所有美学都在一个维度中列出,而所有几何(和其他对象?)在另一个维度中列出,那就太棒了。
有人知道这样的事情吗?
R 中是否有一种简单的方法(命令)来列出可应用于对象的所有美学?
表格的启动方式如下:
List x y fill size colour linetype . . .
geom_point Yes Yes Yes Yes Yes No
geom_abline Yes Yes No Yes Yes Yes
.
.
.
美学定义/参数的目录也是一个非常有用的引用。
最佳答案
下面是每个几何对象的default_aes
,
colour size linetype alpha fill weight shape width height angle hjust vjust family fontface lineheight
abline black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- --
area yes 0.5 1 yes grey20 -- -- -- -- -- -- -- -- -- --
bar yes 0.5 1 yes grey20 1 -- -- -- -- -- -- -- -- --
bin2d yes 0.5 1 yes grey60 1 -- -- -- -- -- -- -- -- --
boxplot grey20 0.5 solid yes white 1 16 -- -- -- -- -- -- -- --
contour #3366FF 0.5 1 yes -- 1 -- -- -- -- -- -- -- -- --
crossbar black 0.5 1 yes yes -- -- -- -- -- -- -- -- -- --
density black 0.5 1 yes yes 1 -- -- -- -- -- -- -- -- --
density2d #3366FF 0.5 1 yes -- 1 -- -- -- -- -- -- -- -- --
errorbar black 0.5 1 yes -- -- -- 0.5 -- -- -- -- -- -- --
errorbarh black 0.5 1 yes -- -- -- -- 0.5 -- -- -- -- -- --
freqpoly black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- --
hex yes 0.5 -- yes grey50 -- -- -- -- -- -- -- -- -- --
hline black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- --
linerange black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- --
path black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- --
point black 2 -- yes yes -- 16 -- -- -- -- -- -- -- --
pointrange black 0.5 1 yes yes -- 16 -- -- -- -- -- -- -- --
polygon NA 0.5 1 yes grey20 -- -- -- -- -- -- -- -- -- --
quantile #3366FF 0.5 1 yes -- 1 -- -- -- -- -- -- -- -- --
raster -- -- -- yes grey20 -- -- -- -- -- -- -- -- -- --
rect yes 0.5 1 yes grey20 -- -- -- -- -- -- -- -- -- --
ribbon yes 0.5 1 yes grey20 -- -- -- -- -- -- -- -- -- --
rug black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- --
segment black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- --
smooth #3366FF 0.5 1 0.4 grey60 1 -- -- -- -- -- -- -- -- --
step black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- --
text black 5 -- yes -- -- -- -- -- 0 0.5 0.5 1 1.2
tile yes 0.1 1 yes grey20 -- -- -- -- -- -- -- -- -- --
violin grey20 0.5 solid yes white 1 -- -- -- -- -- -- -- -- --
vline black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- --
以及我用来破解这个的丑陋代码,
find_aes <- function(geom="point"){
tryCatch({
Geom <- getFromNamespace(paste("Geom", ggplot2:::firstUpper(geom), sep=""),
"ggplot2")
tmp <- unclass(Geom$default_aes)
tmp[is.na(tmp)] <- "yes"
data.frame(tmp, stringsAsFactors=FALSE)
}, error = function(e) {})
}
funs <- grep("^geom_", ls("package:ggplot2"),val=T)
geoms <- gsub("^geom_", "", funs)
all <- lapply(geoms, find_aes)
names(all) <- geoms
relevant <- sapply(all, function(x) !is.null(x) && nrow(x) > 0)
library(plyr)
results = do.call("rbind.fill",all)
rownames(results) <- names(relevant[relevant])
results[is.na(results)] <- "--"
options(width=9999)
capture.output(print(results), file="aes.txt")
关于r - 有没有 ggplot2 的美学表格或目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11657380/
我无法将存储在变量中的 POSIXct 作为 geom_rect 的 xmin/xmax 传递。我试图构建一个独立的示例,而不会轻视我正在尝试做的事情...... 这个想法是采用一个 ggplot2
我想动态修改/创建美感,而无需重新创建geom层。以下是我的代码。 library("ggplot2") dat 3)) 这里我必须修改geom_point以添加美感。这个想法是始终绘制点并动态修改颜
我想更改一组 ggplot 的点和线的默认颜色。 当然,我可以定义一种颜色,然后在每个绘图中显式调用它: my_colour <- "firebrick" ggplot(cars, aes(speed
假设我有两个 ggplot 美学: a.1 c(a.1,a.2) $v.1 [1] 1 $v.2 [1] 2 $v.3 [1] 3 aes对象是“未计算的表达式”和 c()函数按预期工作,具体取决于
我想使用具有 2 美学的包 ggpubr 的 ggline。等效项在 geom_line 中完美运行,但在 ggline 中无效。假设我有这个数据集 data % mutate(a = x^2,
我有以下数据集 map(.x = list(small = 3, medium = 10, large = 100) , .f = ~ sample(rnorm(1000), .x, r
Scatterplot<-ggplot( diamonds[sample(nrow(diamonds), 1000), ], aes(carat, price, colour=cl
我是一名优秀的程序员,十分优秀!