ggally

How to set same scales across different facets with ggpairs()

♀尐吖头ヾ 提交于 2019-11-30 23:28:58
问题 I have the following dataset and codes to construct the 2d density contour plot for each pair of variables in the data frame. My question is whether there is a way in ggpairs() to make sure that the scales are the same for different pairs of variables like the same scale for different facets in ggplot2. For example, I would like the x scale and y scale are all from [-1, 1] for each of the picture. Thanks in advance! The plot looks like library(GGally) ggpairs(df,upper = list(continuous =

Add or override aes in the existing mapping object

南笙酒味 提交于 2019-11-30 20:07:41
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 the documentation, and browsing the source didn't help either. I once seem to have stumbled upon something like AddOrOverrideAes , but no idea where exactly. Here's what my current solution is: add_aes <- function

Add or override aes in the existing mapping object

♀尐吖头ヾ 提交于 2019-11-30 03:51:40
问题 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 the documentation, and browsing the source didn't help either. I once seem to have stumbled upon something like

Edit individual ggplots in GGally::ggpairs: How do I have the density plot not filled in ggpairs?

混江龙づ霸主 提交于 2019-11-29 07:08:47
With library(GGally) data(diamonds, package="ggplot2") diamonds.samp <- diamonds[sample(1:dim(diamonds)[1],200),] # Custom Example ggpairs( diamonds.samp[,1:5], 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" ) I get How do I make the diagonal density plots to not be filled, and only show the lines? Kind of works... but not really. This is really ugly - in terms of code - because

GGally::ggpairs plot without gridlines when plotting correlation coefficient

可紊 提交于 2019-11-28 17:18:48
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")), upper=list(params=list(corSize=6)), axisLabels='show') tonytonov Check out this related question and my forked repo. Use assignInNamespace to modify ggally_cor function as shown in the aforementioned

Arranging GGally plots with gridExtra?

末鹿安然 提交于 2019-11-28 14:02:03
I'd like to arrange my ggpairs plots with arrangeGrob : library(GGally) library(gridExtra) df <- structure(list(var1 = 1:5, var2 = 4:8, var3 = 6:10), .Names = c("var1", "var2", "var3"), row.names = c(NA, -5L), class = "data.frame") p1 <- ggpairs(df, 1:3) p2 <- ggpairs(df, 1:2) p <- arrangeGrob(p1, p2, ncol=2) which results in this error: Error in arrangeGrob(p1, p2, ncol = 2) : input must be grobs! Is there a way to work around this problem? tonytonov Unfortunately, I cannot see how that is possible. First, it's not going to work with gridExtra , since arrangeGrob operates on TableGrob objects

How to add an external legend to ggpairs()?

纵然是瞬间 提交于 2019-11-28 08:34:27
I am plotting a scatterplot matrix using ggpairs . I am using the following code: # Load required packages require(GGally) # Load datasets data(state) df <- data.frame(state.x77, State = state.name, Abbrev = state.abb, Region = state.region, Division = state.division ) # Create scatterplot matrix p <- ggpairs(df, # Columns to include in the matrix columns = c(3,5,6,7), # What to include above diagonal # list(continuous = "points") to mirror # "blank" to turn off upper = "blank", legends=T, # What to include below diagonal lower = list(continuous = "points"), # What to include in the diagonal

GGally::ggpairs plot without gridlines when plotting correlation coefficient

我的梦境 提交于 2019-11-27 10:35:16
问题 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")), upper=list(params=list(corSize=6)), axisLabels='show') 回答1: Check out this related question and my

Change colors in ggpairs now that params is deprecated

百般思念 提交于 2019-11-27 09:45:01
I saw these posts GGally::ggpairs plot without gridlines when plotting correlation coefficient use ggpairs to create this plot After reading I was able to implement this hack https://github.com/tonytonov/ggally/blob/master/R/gg-plots.r and my plot looks like this I think this is a good result but I cannot change the colors. A MWE is this library(ggally) # load the hack source("ggally_mod.R") # I saved https://github.com/tonytonov/ggally/blob/master/R/gg-plots.r as "ggally_mod.R" assignInNamespace("ggally_cor", ggally_cor, "GGally") ggpairs(swiss) Now I want to run ggpairs(swiss, lower=list

use ggpairs to create this plot

懵懂的女人 提交于 2019-11-27 04:07:12
I have some code in a Shiny app that produces the first plot below. As you can see the font size varies with the size of the correlation coefficient. I would like to produce something similar with ggpairs (GGally) or ggplot2. The second image below was produced with the following code: library(GGally) ggpairs(df, upper = list(params = c(size = 10)), lower = list(continuous = "smooth", params = c(method = "loess", fill = "blue")) ) As you can see the size of the correlation font is adjustable using size but when I set a vector of sizes only the first value is used. I would also like to remove