I generated two different graphics which have different labels, is it possible two merge it?
library(corrplot)
par(mfrow=c(1,2))
col<- colorRampPalette(c("#78CB65","#EBF6DF","#AEDAAA"))
corrplot(as.matrix(samp4), is.corr = FALSE, type = 'lower', method = 'color', addCoef.col = 'black', number.cex=0.50,
col=col(11),
tl.col = "black",
tl.cex = 0.8,
title = "OrthoANI")
corrplot(as.matrix(ddh2), is.corr = FALSE, type = 'upper', method = 'color', addCoef.col = 'black', number.cex=0.50,
col=col(11),
tl.col = "black",
tl.cex = 0.8,
title = "ddh")
I would like two merge it like this
I tried making only one data from ddh2 and samp4, but the problem is that the threshold and values are different, so the label has to be different
thanks
Related
The code I have written produces the image attached here. I'm wanting to make the asterisks smaller in size, but I am not sure how to do this. Also, is it possible to represent different levels of significance with the number of asterisks (*=0.1, **=0.05, ***=0.001). Thanks in advance. My code and figure are below as well.
alpha_corr <- cor(Schiller_Numerical, method = "pearson")
alpha_p <- cor.mtest(alpha_corr, method = "pearson", conf.level = 0.95, exact = FALSE)
corrplot(
cor(alpha_corr, method = "pearson"),
tl.col = "black",
tl.srt = 60,
method = 'square',
order = 'hclust',
type = 'lower',
diag = TRUE,
tl.cex = 1,
title = "Heatmap For All Data",
mar=c(0,0,2,0),
p.mat = alpha_p$p,
sig.level = 0.05,
insig = "label_sig") `
You can find all the useful parameters you required in the corrplot() documentation : https://www.rdocumentation.org/packages/corrplot/versions/0.92/topics/corrplot
You need to modify pch.cex to adjust asdterisk size, and sig.level to specify the signficance levels as a vector.
data(mtcars)
alpha_p <- cor.mtest(mtcars, method = "pearson", conf.level = 0.95, exact = FALSE)
corrplot(
cor(mtcars, method = "pearson"),
tl.col = "black",
tl.srt = 60,
method = 'square',
order = 'hclust',
type = 'lower',
diag = TRUE,
tl.cex = 1,
title = "Heatmap For All Data",
mar=c(0,0,2,0),
p.mat = alpha_p$p,
sig.level = c(0.001,0.05,0.1),
insig = "label_sig",
pch.cex=1)
Is it possible to add a label that applies to a few variables in a corrplot? This is an example of what I'm after. In that case it is the word "Petals" on the y-axis.
Below is the code to make the rest of the plot.
library(corrplot)
library(Hmisc)
iris_c <- iris[, c(1:4)]
test <- rcorr(as.matrix(iris_c))
corrplot(test$r, type="lower", order= "original",
p.mat = test$P, sig.level = 0.01, insig = "blank",
col= colorRampPalette(c("blue","white", "red"))(100), tl.col = 'black', cl.ratio = 0.8, tl.srt = 45, diag = FALSE, method = "square")
You can use title() to adjust axis labels, which is what you're looking for here. After running your code above, just run:
title(ylab = "Petals")
I am trying to use plot the boxplot to show the variable importance but cannot get the boxplot to show the 4 different color, the plots which I get are black in color. I am using Boruta version 6.
Does the plot function depend on another package?
I have used the following code;
1. plot(boruta_output, las = 2, cex.axis = 0.7)
2. plot(boruta_output, colCode = c("green", "yellow", "red", "blue"),
sort = TRUE, whichShadow = c(TRUE, TRUE, TRUE), col = NULL,
xlab = "Attributes", ylab = "Importance")
I have a 1 row 2 column plot which I need to insert into a report. When I insert the plot I notice there's a large white area around both correlation plots. Is there an argument in the corrplot function to reduce this? I've read here about using knitr hook functions to crop pdfs but that a bridge too far for my coding capabilities. I've messed around with the par() arguments such as omi and mai but when I export the image to TIFF I still get a huge white space area.
My code so far looks as follows, please note this is hacked together from various sources and dputs to both correlation matrices can be found here and here:
col <- colorRampPalette(c("#BB4444", "#EE9988", "#FFFFFF", "#77AADD", "#4477AA"))
par(mfrow=c(1,2),omi=c(0,0,0,0),mai=c(0.1,0.1,0.1,0.1))
corrplot(LX0088U21A1_24hrCor, method = "color", col = col(200),
type = "upper", order = "original", number.cex = 0.85,
addCoef.col = "black", # Add coefficient of correlation
tl.col = "black", tl.srt = 90,
number.digits = 1,
# Text label color and rotation
# hide correlation coefficient on the principal diagonal
diag = FALSE,
#title = "Intraday Correlation LX0088U21A1",
mar=c(0,0,1,0))
legend(0.5,5,ncol = 1, cex = 1.5,legend = "(a)", box.lwd = 0, box.col = "white")
corrplot(LX0088U09A3_24hrCor, method = "color", col = col(200),
type = "upper", order = "original", number.cex = 0.75,
addCoef.col = "black", # Add coefficient of correlation
tl.col = "black", tl.srt = 90,
number.digits = 1,
# Text label color and rotation
# hide correlation coefficient on the principal diagonal
diag = FALSE,
#title = "Intraday Correlation LX0088U09A3",
mar=c(0,0,1,0))
legend(0.5,5,ncol = 1, cex = 1.5,legend = "(b)", box.lwd = 0, box.col = "white")
Any help is greatly appreciated.
I'm using the VennDiagram R package to try to generate a neatly formatted diagram comparing two groups. I have successfully used this package in the past to compare relatively similarly-sized groups. However, now I'm comparing groups that have significantly different sizes (# of unique elements in the first group is ~3,600, # of unique elements in the second group is ~60, and # of overlapping elements is ~80).
The appearance of my current Venn diagram is that the group with the larger # of elements has this value displayed within its circle, but the labels for the intersection of the two groups and the unique elements in the second group are too large to be included in those regions of the diagram, so instead, they are displayed outside of the diagram with a line connecting them to the associated region. I don't like the appearance of this, and would like to reduce the size of all 3 labels so that they can be displayed within their respective regions of the diagram. However, after having reviewed the associated documentation/examples and publication (Chen & Boutros 2011), I'm still not clear about how to do this. (For example, I see parameters that permit the specification of font size of the figure title and subtitle, but I don't see where the labels' font size can be specified...)
I have attempted workarounds such as trying to make the labels invisible so that I can manually add them in a separate application, but this doesn't seem to be an option...
Any suggestions for how I can reduce the font size of my labels and specify that these labels appear within the regions of the diagram rather than outside of the diagram, will be appreciated. Thanks!
Update: As requested below, I am providing my example code:
library(VennDiagram);
library(grid);
Data <- read.csv('ExampleDataset_VennDiagram.csv')
Dataset1 <- Data[,1]
Dataset2 <- Data[,2]
MyVennDiagram <- venn.diagram(
x = list(
A = Dataset1,
B = Dataset2
),
main = "",
main.cex = NULL,
filename = NULL,
lwd = 2,
fill = c("blue", "green"),
alpha = 0.75,
label.col = "black",
cex=c(2,2,2),
fontfamily = "sansserif",
fontface = "bold",
cat.col = c("blue", "green"),
cat.cex = 0,
cat.fontfamily = "serif",
cat.fontface = "bold",
cat.dist = c(0.05, 0.05),
cat.pos = c(-20, 14),
);
grid.newpage()
grid.draw(MyVennDiagram)
Update: Based on missuse's suggestion below, using ext.text = FALSE works perfectly!
Thanks to everyone who contributed to this thread.
The eulerr library appears to generate nice-looking diagrams, and will definitely be a resource I use in the future -- thanks for sharing.
A possible solution to this is to avoid using euler diagrams.
To illustrate your problem here is some data:
A = sample(1:1000, 500, replace = T)
B = sample(1:10000, 50)
Here is the diagram obtained by
library(VennDiagram);
library(grid)
MyVennDiagram = venn.diagram(
x = list(
A = A,
B = B
),
main = "",
main.cex = NULL,
filename = NULL,
lwd = 2,
fill = c("cornflowerblue", "pink"),
alpha = 0.75,
label.col = "black",
cex=c(2,2,2),
fontface = "plain",
cat.col = c("cornflowerblue", "pink"),
cat.cex = 0,
cat.fontfamily = "serif",
cat.fontface = "plain",
cat.dist = c(0.05, 0.05),
cat.pos = c(-20, 14),
cat.default.pos = "text",
)
grid.newpage()
grid.draw(MyVennDiagram)
by avoiding scaling of the circles with scaled = FALSE
MyVennDiagram = venn.diagram(
x = list(
A = A,
B = B
),
main = "",
main.cex = NULL,
filename = NULL,
lwd = 2,
fill = c("cornflowerblue", "pink"),
alpha = 0.75,
label.col = "black",
cex=c(2,2,2),
fontface = "plain",
cat.col = c("cornflowerblue", "pink"),
cat.cex = 0,
cat.fontfamily = "serif",
cat.fontface = "plain",
cat.dist = c(0.05, 0.05),
cat.pos = c(-20, 14),
cat.default.pos = "text",
scaled = FALSE
)
grid.newpage()
grid.draw(MyVennDiagram)
As per user20650 suggestion the best option is to use ext.text=FALSE in the original call:
Also check library(eulerr) it accepts a bit different input, here is an illustration:
library(eulerr)
library(tidyverse)
data.frame(dat = unique(c(A, B))) %>%
mutate(A = dat %in% A,
B = dat %in% B) %>%
select(A, B) %>%
euler() %>%
eulerr:::plot.euler(counts = T)
As per user20650 comment acceptable input is also:
plot(euler(setNames(list(unique(A),unique(B)), c("A", "B"))), counts=TRUE)