更新:
GGAllyを再び更新し、この答えでハックはもはもう動作しませんが、最終的には非があります-hackソリューション:
scales <- scale_colour_brewer(type = 'qual') %+% scale_fill_brewer(type = 'qual')
を与えられたあなたは(うまくいけば、将来性の方法で)
0を行うことができます
for (row in seq_len(ps$nrow))
for (col in seq_len(ps$ncol))
ps[row, col] <- ps[row, col] + scales
古い方法
他の答えでハックはもう動作し、それでは、新しいものをハックすることはできません!、プロットオブジェクト内の各文字列を変更する必要がプロットを変更するために
> dta <- data.frame(a=1:6, b=7:12, c=c('f', 'g'))
> ps <- ggpairs(dta, 1:2, colour = 'c')
> str(ps)
List of 10
$ data :'data.frame': 2 obs. of 3 variables:
..$ a: int [1:2] 1 2
..$ b: int [1:2] 3 4
..$ c: int [1:2] 5 6
$ columns : int [1:3] 1 2 3
$ plots :List of 9
..$ : chr "ggally_densityDiag(ggally_data, ggplot2::aes(x = a, colour = c))"
..$ : chr "ggally_cor(ggally_data, ggplot2::aes(x = b, y = a, colour = c))"
[...]
$ gg : NULL
- attr(*, "class")= chr [1:2] "gg" "ggpairs"
> ps
:
ggpairs
物体の内部構造は、データセットと文字列のリストであります追加のコマンドを含める。このために、我々はdeparse(substitute(argument))
を使用するユーザーは、渡されたコードを含む文字列を取得するには、すべてのプロットコールにそれを追加します。
add_to_plots <- function(pairs, modification) {
str <- deparse(substitute(modification))
pairs$plots <- lapply(pairs$plots, function(s) paste(s, '+', str))
pairs
}
> add_to_plots(ps, scale_colour_brewer(type = 'qual'))
素敵なハックを!うまくいけば、これは良いことの間信頼できる。 –