corrplot icon indicating copy to clipboard operation
corrplot copied to clipboard

`corrplot()` with `corrRect()` using the name parameter not providing expected results

Open adcascone opened this issue 11 months ago • 1 comments

Hello,

I'm trying to reproduce this output in the 'An introduction to corrplot package' vignette:

Image

I am running this code, which is copy/pasted from the vignette:

library(dplyr)
library(seriation)
data(Zoo)
Z = cor(Zoo[, -c(15, 17)])

# use name parameter
# Since R 4.1.0, the following one line code works:
# corrplot(M, order = 'AOE') |> corrRect(name = c('gear', 'wt', 'carb'))
corrplot(Z, order = 'AOE') %>%
  corrRect(name = c('tail', 'airborne', 'venomous', 'predator'))

My output does not match the vignette, though. Instead, this is the plot I am seeing:

Image

Is the plot included in the vignette outdated? Or is this indicative of a bug in the functions used? Based on my knowledge, I believe the output should look like what's currently shown in the vignette, not what I am producing on my own.

For reference, I'm using corrplot version 0.95

Thank you for your time!

Arianna C.

adcascone avatar Jan 29 '25 19:01 adcascone

Hi @adcascone,

The vignette code works for me on R 4.4.0. I also tested R 4.0.0 (per the comment "Since R 4.1.0...") and that worked too. Which version of R are you using?

The issue seems to be that the ordering of rows and columns differs from how they should be ordered when using order=AOE. Given this, I think corrRect is behaving as expected. Is it possible that you have re-arranged the correlation matrix in an earlier bit of code?

Otherwise, it could possibly be an issue reorder_using_aoe but looking at the code I can't see what the issue could be. I have tested the other clustering methods and none of them match the row ordering shown in the image. I am not able to reproduce the issue.

jeffzemla avatar Dec 01 '25 21:12 jeffzemla