This might help you One option would be to not use the complete correlation dataset and filter out only one half of the matrix using upper.tri. You could even consider setting its diag argument to TRUE to get rid of the arguably unnecessary diagonal ones. How about the below? code :
# Load data
library(plotly)
data("mtcars")
my_data < mtcars[, c(1,3,4,5,6,7)]
# print the first 6 rows
head(my_data, 6)
res < cor(my_data)
res[upper.tri(res)] < NA
round(res, 2)
plot_ly(x=colnames(res), y=rownames(res), z = res, type = "heatmap") %>%
layout(
xaxis=list(tickfont = list(size = 30), tickangle = 45),
margin = list(l = 150, r = 50, b = 150, t = 0, pad = 4))
Share :

Heatmap or plot for a correlation matrix
By : Andy
Date : March 29 2020, 07:55 AM
around this issue @Lucas provides good advice here as corrplot is quite useful for visualizing correlation matrices. However, it doesn't address the original issue of plotting a large correlation matrix. In fact, corrplot will also fail when trying to visualize this large of a correlation matrix. For a simple solution, you might want to consider reducing the number of variables. That is, I would suggest looking at the correlation between a subset of variables that you know are important for your problem. Trying to understand the correlation structure of that many variables will be a difficult task (even if you can visualize it)!

Lower triangle correlation heatmap
By : user6714133
Date : March 29 2020, 07:55 AM
I wish this help you Well, I reproduced your script and this is my plot Just change code :
ggplot(cor.mat.df ,aes(sample2, sample1, fill=correlation))+
geom_tile(color="white")+
scale_fill_gradient2(low="blue", high="red", mid="white", midpoint=0, limit=c(1,1), space="Lab", name="Pearson\nCorrelation")+
theme_bw()+
theme(axis.text.x=element_text(angle=45,vjust=1,size=10,hjust=1))+
coord_fixed()+
labs(x="",y="")
ggplot(cor.df, aes(sample2, sample1, fill=correlation))+
geom_tile(color="white")+
scale_fill_gradient2(low="blue", high="red", mid="white", midpoint=0, limit=c(1,1), space="Lab", name="Pearson\nCorrelation")+
theme_bw()+
theme(axis.text.x=element_text(angle=45, vjust=1, size=10, hjust=1))+
coord_fixed()+
labs(x="",y="")
R version 3.3.2 (20161031)
Platform: x86_64w64mingw32/x64 (64bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=Spanish_Colombia.1252 LC_CTYPE=Spanish_Colombia.1252
[3] LC_MONETARY=Spanish_Colombia.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Colombia.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_2.2.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.8 digest_0.6.11 assertthat_0.1 grid_3.3.2 plyr_1.8.4
[6] gtable_0.2.0 magrittr_1.5 scales_0.4.1 stringi_1.1.2 reshape2_1.4.2
[11] lazyeval_0.2.0 labeling_0.3 tools_3.3.2 stringr_1.1.0 munsell_0.4.3
[16] colorspace_1.32 tibble_1.2

Using a heatmap to reflect differences between correlation dataframes and displaying only lower triangle
By : user508915
Date : March 29 2020, 07:55 AM
this will help I have the above heatmap that I generate using the below: , If p4 is a matrix, you can use upper.tri as: code :
p4[upper.tri(p4)] < NA
melt_p4 < melt(p4)
melt_p4 < melt_p4[!is.na(melt_p4$value),]
colnames(melt_p4) < c("Var1", "Var2", "value")
ggplot(melt_p4, aes(Var1, Var2)) +
geom_tile(aes(fill = value), color = "white") +
labs(title = "ST  LT Correlation Across Factor") +
scale_fill_gradient(low = "red", high = "green") +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
geom_text(aes(label = round(value, 1)), size = 2.2) +
theme_bw() +
scale_x_discrete(expand=c(0,0)) +
scale_y_discrete(expand=c(0,0))
set.seed(1)
p4 < matrix(runif(16, 0, 1), nrow = 4, ncol = 4)
row.names(p4) < c("A", "B", "C", "D")
colnames(p4) < c("A", "B", "C", "D")

Heatmap of correlation matrix using seaborn not displaying properly at the top and bottom row
By : semistandard
Date : March 29 2020, 07:55 AM
This might help you Upgrading matplotlib to the last version (3.1.3) should solve the issue. using anaconda: conda update matplotlib using pip: pip install U matplotlib

How to animate a seaborn's heatmap or correlation matrix?
By : David Ding
Date : March 29 2020, 07:55 AM
wish helps you I replaced plt.imshow (casting data via set_data didn't work) with seaborn.heatmap.

