这与R和ggpairs中用户定义的调色板中的问题相同 ,或者有没有办法使用ggplot更改GGally :: ggpairs的调色板?
只有那里的解决方案不再有效.
我也想更改调色板,但有没有办法使用ggplot更改GGally :: ggpairs的调色板?不再起作用了.该怎么办?
MWE:
library(GGally)
library(ggplot2)
data(diamonds, package="ggplot2")
diamonds.samp <- diamonds[sample(1:dim(diamonds)[1],200),]
ggpairs(
diamonds.samp[,1:2],
mapping = ggplot2::aes(color = cut),
upper = list(continuous = wrap("density", alpha = 0.5), combo = "box"),
lower = list(continuous = wrap("points", alpha = 0.3), combo = wrap("dot", alpha = 0.4)),
diag = list(continuous = wrap("densityDiag")),
title = "Diamonds"
)
Run Code Online (Sandbox Code Playgroud)
我想补充一下
scale_colour_manual(values=c('red','blue','green','red','blue'))
Run Code Online (Sandbox Code Playgroud)
(显然这只是虚拟代码)并得到类似的东西(我没有绘制所有的点):
'sparcl'包使用标准'stat'包中的'kmeans'函数.我想让它使用我自己的kmeans ++实现.
一种方法是编辑sparcl包本身的代码.我宁愿避免这种情况,因为它会很混乱,因为我不确定如何在R中安装编辑过的代码.
不幸的是,超级运算符"<< - "不起作用:
> kmeans <<- function(x) print("hi!")
Error: cannot change value of locked binding for 'kmeans'
Run Code Online (Sandbox Code Playgroud)
也没有"分配":
assign("kmeans",function(x) {print("HI THERE!"); return(FALSE)},pos="package:sparcl")
Error in assign("is.null", function(x) { :
cannot add bindings to a locked environment
Run Code Online (Sandbox Code Playgroud)
那么编辑包代码是唯一的方法吗?
谢谢!
我想创建一个大小的网格划分N倍N哪里N是字段数。我试图得到的网格图有点像 Weka 中的图:一个多图,其中每一行都是数据框的一个字段,每列也是一个字段。诀窍是我想获得矩阵散点图的更通用版本。我想要更丰富的数据,没有重复:例如,对角线值可以有分布。
威卡。矩阵散点图浪费了很多空间,我们可以丰富它吗?
基本的R解决方案1.plot(iris)同样的浪费空间的问题,为什么我们有对角线?
看起来像是从维基百科以某种方式使用 R 基本命令创建的 R 解决方案 2。
R 中的小演示(计算时间太长)
library(gridExtra)
library(grid)
library(ggplot2)
#library(lattice)
data(iris)
p1 <- ggplot(data=iris,aes(x=Sepal.Length, y=Sepal.Length)) + geom_point()
p2 <- ggplot(data=iris,aes(x=Sepal.Length, y=Sepal.Width)) + geom_point()
p3 <- ggplot(data=iris,aes(x=Sepal.Length, y=Petal.Length)) + geom_point()
p4 <- ggplot(data=iris,aes(x=Sepal.Length, y=Petal.Width)) + geom_point()
p5 <- ggplot(data=iris,aes(x=Sepal.Length, y=Species)) + geom_point()
grid.arrange(p1, p2, p3, p4, p5, ncol=length(names(iris)))
#ERROR: In as.list(X): reached elapsed time limit
# https://cran.r-project.org/web/packages/gridExtra/vignettes/arrangeGrob.html
Run Code Online (Sandbox Code Playgroud)
及其会话信息
version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: …Run Code Online (Sandbox Code Playgroud)