I wanted to make a ggpairs plot of the mtcars data set, but I only care about the relationship between mpg and all the other variables, not between all of the variables and all of the variables. I changed some of the columns to factors mtcars$cyl = as.factor(mtcars$cyl) mtcars$vs = as.factor(mtcars$vs) mtcars$am = as.factor(mtcars$am) mtcars$gear = as.factor(mtcars$gear) mtcars$carb = as.facto
我想制作mtcars数据集的ggpairs图,但我只关心mpg和所有其他变量之间的关系,而不关心所有变量和所有变量之间的关系。 我改变了一些列的因素 mtcars$cyl = as.factor(mtcars$cyl) mtcars$vs = as.factor(mtcars$vs) mtcars$am = as.factor(mtcars$am) mtcars$gear = as.factor(mtcars$gear) mtcars$carb = as.factor(mtcars$carb) 并绘制情节 ggpairs(mtcars, colour = "am", columns = c(1,2,8:11)) 有什么方法可以显示剧
I am having problems with the ggpairs colour mapping. When the variable used to set the colour is a character (converted to a factor), things work as expected: library(GGally) data(state) df <- data.frame(state.x77, State = state.name, Abbrev = state.abb, Region = state.region, Division = state.division ) col.index <- c(3,5,6,7) p &l
我对ggpairs颜色映射有问题。 当用于设置颜色的变量是一个字符(转换为一个因子)时,事情按预期工作: library(GGally) data(state) df <- data.frame(state.x77, State = state.name, Abbrev = state.abb, Region = state.region, Division = state.division ) col.index <- c(3,5,6,7) p <- ggpairs(df, # columns to include in the matrix co
GGally::ggpairs plots nice graphs like following one. Only thing I seek to refine it even more is to remove all gridlines in upper part of plot, where is correlation coefficient. An maybe also draw rectangle around each upper graph. library("GGally") data(iris) ggpairs(iris[, 1:4], lower=list(continuous="smooth", params=c(colour="blue")), diag=list(continuous="bar", params=c(colour="blue")),
GGally::ggpairs绘制出如下图所示的漂亮图形。 我唯一需要改进的地方就是删除所有绘图上部的网格线,相关系数在哪里。 也可能在每个上图上画一个矩形。 library("GGally") data(iris) ggpairs(iris[, 1:4], lower=list(continuous="smooth", params=c(colour="blue")), diag=list(continuous="bar", params=c(colour="blue")), upper=list(params=list(corSize=6)), axisLabels='show') 看看这个相关的问题和我的分叉回
Here's the minimal case: df <- data.frame(x=1:5, y=1, col=1:5) mapping <- aes(x=x, y=y) ggplot(df, mapping) + geom_point(size=10) Now I want to add (or overwrite) another aesthetic (colour) to the existing mapping object. The desired plot is ggplot(df, aes(x=x, y=y, colour=col)) + geom_point(size=10) I'm sure there exists a convenience function for this, but it is not listed in
这是最小的情况: df <- data.frame(x=1:5, y=1, col=1:5) mapping <- aes(x=x, y=y) ggplot(df, mapping) + geom_point(size=10) 现在我想添加(或覆盖)另一种审美(颜色)到现有的mapping对象。 所需的情节是 ggplot(df, aes(x=x, y=y, colour=col)) + geom_point(size=10) 我确定这里有一个方便的功能,但它没有在文档中列出,浏览源也没有帮助。 我曾经似乎偶然发现了AddOrOverrideAes类的AddOrOverrideAes ,
One of my favorite tools for exploratory analysis is pairs() , however in the case of a limited number of discrete values, it falls flat as the dots all align perfectly. Consider the following: y <- t(rmultinom(n=1000,size=4,prob=rep(.25,4))) pairs(y) It doesn't really give a good sense of correlation. Is there an alternative plot style that would? If you change y to a data.frame you
探索性分析最喜欢的工具之一是pairs() ,但是在数量有限的离散值的情况下,由于点完全对齐,因此它会变得平坦。 考虑以下: y <- t(rmultinom(n=1000,size=4,prob=rep(.25,4))) pairs(y) 它并没有给出很好的相关性。 有没有另一种情节风格? 如果将y更改为data.frame,则可以添加一些“抖动”,使用col选项可以设置透明度级别(rgb中的第4个数字): y <- data.frame(y) pairs(sapply(y,jitter), col = rgb(0,0,0,.2))
Hi this simple code (and all my scripts from this morning) has started giving me a off center title in ggplot2 Ubuntu version: 16.04 R studio version: Version 0.99.896 R version: 3.3.2 GGPLOT2 version: 2.2.0 I have freshly installed the above this morning to try and fix this.... dat <- data.frame( time = factor(c("Lunch","Dinner"), levels=c("Lunch","Dinner")), total_bill = c(14.89, 17.23
你好这个简单的代码(以及我今天早上的所有脚本)已经开始给我一个ggplot2的偏离中心的标题 Ubuntu version: 16.04 R studio version: Version 0.99.896 R version: 3.3.2 GGPLOT2 version: 2.2.0 今天早上我刚刚安装了上述内容,试图解决这个问题.... dat <- data.frame( time = factor(c("Lunch","Dinner"), levels=c("Lunch","Dinner")), total_bill = c(14.89, 17.23) ) # Add title, narrower bars, fill color, a
I wanted to create some maps by using ggplot2, but I am struggling to find the best way. Since I have a list ("models") with matrix, I wanted to use ggplot because then, it should be easier to create a multiplot (with facet_wrap..but just a thought). I will create an reproducible example for doing this: #European corrdinates lon <- rep(loni,38) #longitude values -13W-34E lat <
我想通过使用ggplot2创建一些地图,但我正在努力寻找最佳方式。 由于我有一个带有矩阵的列表(“模型”),因此我想使用ggplot,因此创建一个多槽(与facet_wrap ..但只是一个想法)应该更容易。 我将为此创建一个可重复的示例: #European corrdinates lon <- rep(loni,38) #longitude values -13W-34E lat <- rep(lati, each = 48) #latitude values 34N-70N #Matrix of values mod <- matrix( rnorm(48*38,mean=0,
I'm trying to plot 30 histograms from a data frame 'data.frame': 569 obs. of 32 variables: $ ID : int 842302 842517 84300903 84348301 84358402 843786 844359 84458202 844981 84501001 ... $ Diag : Factor w/ 2 levels "B","M": 2 2 2 2 2 2 2 2 2 2 ... $ Radius : num 5.1 5.84 5.59 3.24 5.76 ... $ Text : num 2.41 4.13 4.94 4.74 3.33 ... etc.... I want to group all th
我试图从数据框中绘制30个直方图 'data.frame': 569 obs. of 32 variables: $ ID : int 842302 842517 84300903 84348301 84358402 843786 844359 84458202 844981 84501001 ... $ Diag : Factor w/ 2 levels "B","M": 2 2 2 2 2 2 2 2 2 2 ... $ Radius : num 5.1 5.84 5.59 3.24 5.76 ... $ Text : num 2.41 4.13 4.94 4.74 3.33 ... etc.... 我想将Diag(Malign或Benign癌症)的所有属性组
Possible Duplicate: how to define fill colours in ggplot histogram? I want to plot (histogram) counts of fishes per length class from a data frame which summarize this information in a binned format (data.frame(...,length=length, counts=N)). I'm a new user of ggplot2, but seems It could be a good choice. Can I create this histogram from a data.frame object? Sorry for being so brief, H
可能重复: 如何在ggplot直方图中定义填充颜色? 我想从以分箱格式(data.frame(...,length = length,counts = N))汇总此信息的数据框绘制每个长度类别的鱼类数量(直方图)。 我是ggplot2的新用户,但似乎它可能是一个不错的选择。 我可以从data.frame对象创建这个直方图吗? 对不起,这么简短,这里是一块df的结构, 'data.frame': 416 obs. of 3 variables: $ specie: Factor w/ 1 level "speciesA": 1 1 1
I plot the following: library(ggplot2) carrots <- data.frame(length = rnorm(500000, 10000, 10000)) cukes <- data.frame(length = rnorm(50000, 10000, 20000)) carrots$veg <- 'carrot' cukes$veg <- 'cuke' vegLengths <- rbind(carrots, cukes) ggplot(vegLengths, aes(length, fill = veg)) + geom_density(alpha = 0.2) Now say I only want to plot the region between x=-5000 to 5000 , in
我绘制以下内容: library(ggplot2) carrots <- data.frame(length = rnorm(500000, 10000, 10000)) cukes <- data.frame(length = rnorm(50000, 10000, 20000)) carrots$veg <- 'carrot' cukes$veg <- 'cuke' vegLengths <- rbind(carrots, cukes) ggplot(vegLengths, aes(length, fill = veg)) + geom_density(alpha = 0.2) 现在说我只想绘制x=-5000到5000之间的区域,而不是整个范围。 我怎样才能