1

I did a GGally-ggpairs-plot (see below) with now having the following issue:
The y-axis of the first variable PdKeyT is labelled with the incorrect values (yellow), instead should be labelled with values according to its x-axis from minus 25 to plus 75 (green). I cannot figure out / explain why, as the code seems ok, and especially as the other variables are labelled correctly (each with the same range at both axes).

Any ideas?

Below the image you will find two code samples.
The first one shows only the corr- and plot-section.
The second is (should be) the complete, reproducible sample with (quite long) df-section ahead.

enter image description here

Here the corr- and plot section of the code:

CorrPoint_LevelvsBands <- round(cor(subset(loopsubset_created[c(45,16:25)])),2)
print(CorrPoint_LevelvsBands)

# Computing correlation matrix with p-values
CorrPoint_LevelvsBands_PVal <- cor_pmat(loopsubset_created[c(45,16:25)])
print(CorrPoint_LevelvsBands_PVal)

print(
  ggpairs(loopsubset_created[c(45,16:25)],
          title = paste("Corr. analysis"),
          lower = list(continuous = wrap("cor",
                                         size = 3)),
          upper = list(
            continuous = wrap("smooth",
                              alpha = 0.3,
                              size = 0.1))
  ) +
    theme(axis.text.x = element_text(angle = 90, hjust = 1, size=8)) +
    theme(axis.text.y = element_text(hjust = 1, size=8))
)

Here the full code with df ahead:

loopsubset_created<-structure(list(Site_ID = c("A", "A", "A", "A", "A", "A", "A", 
  "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", 
  "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", 
  "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A"
), Spot_Nr = c("1", "1", "1", "1", "1", "1", "1", "1", "1", "1", 
  "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", 
  "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", 
  "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"), Transkt_Nr = c("2", 
  "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", 
  "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", 
  "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", 
  "2", "2", "2", "2", "2", "2"), Point_Nr = c("8", "8", "8", "8", 
  "8", "8", "8", "8", "8", "8", "8", "8", "8", "8", "8", "8", "8", 
  "8", "8", "8", "8", "8", "8", "8", "8", "8", "8", "8", "8", "8", 
  "8", "8", "8", "8", "8", "8", "8", "8", "8", "8", "8", "8", "8", 
  "8", "8", "8"), n = c(46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 
  46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 
  46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 
  46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L, 46L), 
rank = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
  1L, 1L, 1L, 1L), Date = c(20190208L, 20190213L, 20190215L, 
  20190218L, 20190223L, 20190228L, 20190302L, 20190305L, 20190315L, 
  20190320L, 20190322L, 20190325L, 20190330L, 20190401L, 20190416L, 
  20190419L, 20190421L, 20190501L, 20190506L, 20190524L, 20190531L, 
  20190603L, 20190618L, 20190625L, 20190628L, 20190705L, 20190710L, 
  20190720L, 20190730L, 20190804L, 20190809L, 20190814L, 20190817L, 
  20190827L, 20190903L, 20190911L, 20190913L, 20190916L, 20190921L, 
  20191008L, 20191023L, 20191026L, 20191110L, 20191130L, 20191205L, 
  20191210L), Point_ID = c("1026", "1026", "1026", "1026", 
  "1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026", 
  "1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026", 
  "1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026", 
  "1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026", 
  "1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026", 
  "1026", "1026"), BLUE = c(1173, 1131, 888, 1045, 997, 938, 
  780, 832, 1248, 1147, 1124, 1114, 1156, 1140, 1265, 1375, 
  1244, 2250, 2375, 2000, 2700, 2652, 2087, 1303, 1637, 700, 
  1235, 1258, 1342, 1369, 1140, 1418, 1352, 1767, 1159, 1530, 
  1321, 1566, 1468, 1325, 1274, 1354, 2563, 2880, 1777, 1480
  ), GREEN = c(1242, 1265, 993, 1251, 1302, 1264, 1176, 1171, 
  1442, 1469, 1450, 1448, 1524, 1530, 1385, 1601, 1451, 2381, 
  2447, 2163, 3052, 2727, 2354, 1498, 1938, 817, 1427, 1476, 
  1586, 1535, 1388, 1895, 1619, 2172, 1395, 1731, 1525, 1829, 
  1716, 1538, 1477, 1583, 2954, 3139, 1815, 1571), RED = c(880, 
  992, 835, 947, 976, 918, 849, 826, 1285, 1190, 1249, 1213, 
  1273, 1327, 1322, 1659, 1495, 1617, 1746, 1991, 2204, 1870, 
  1880, 1166, 1694, 625, 1096, 1206, 1266, 1302, 1102, 1944, 
  1377, 1793, 1162, 1613, 1393, 1747, 1692, 1399, 1316, 1516, 
  2683, 2219, 1622, 1573), REDEDGE1 = c(634, 794, 670, 869, 
  953, 1057, 1028, 924, 1265, 1230, 1193, 1242, 1313, 1412, 
  1208, 1552, 1322, 1204, 1299, 1834, 1665, 1424, 1637, 1131, 
  1696, 606, 1052, 1256, 1351, 1344, 1168, 1859, 1367, 1716, 
  1234, 1562, 1321, 1694, 1773, 1389, 1397, 1600, 2285, 1676, 
  1448, 1350), REDEDGE2 = c(112, 198, 201, 300, 361, 594, 376, 
  332, 809, 511, 575, 615, 700, 861, 811, 1128, 807, 428, 331, 
  1255, 620, 731, 964, 636, 1253, 360, 520, 701, 869, 1104, 
  620, 1127, 837, 1164, 772, 1131, 838, 1220, 1313, 927, 903, 
  1267, 1098, 586, 932, 926), REDEDGE3 = c(107, 188, 185, 277, 
  377, 576, 317, 328, 842, 492, 565, 643, 722, 872, 842, 1070, 
  893, 504, 303, 1289, 639, 763, 987, 660, 1283, 406, 538, 
  744, 906, 1183, 698, 1168, 853, 1190, 802, 1170, 893, 1188, 
  1306, 904, 914, 1261, 1056, 537, 932, 940), BROADNIR = c(79, 
  155, 164, 193, 340, 453, 294, 250, 801, 408, 558, 531, 663, 
  834, 839, 1097, 932, 412, 305, 1181, 566, 677, 840, 448, 
  986, 229, 314, 559, 569, 1071, 400, 875, 581, 920, 446, 802, 
  662, 1073, 1131, 679, 674, 1005, 892, 428, 923, 1117), NIR = c(21, 
  55, 70, 145, 233, 402, 125, 189, 677, 225, 261, 380, 477, 
  535, 651, 797, 617, 305, 146, 1033, 399, 689, 923, 530, 1187, 
  347, 341, 690, 813, 1213, 535, 919, 787, 1041, 756, 982, 
  777, 1097, 1133, 880, 824, 1261, 651, 281, 751, 797), SWIR1 = c(92, 
  136, 95, 88, 237, 173, 134, 182, 392, 119, 121, 215, 219, 
  209, 302, 146, 149, 214, 155, 560, 241, 574, 634, 416, 981, 
  256, 390, 649, 840, 928, 582, 683, 901, 924, 940, 818, 804, 
  1045, 1099, 871, 964, 1265, 118, 136, 425, 390), SWIR2 = c(78, 
  85, 70, 81, 189, 128, 128, 128, 289, 96, 122, 130, 176, 163, 
  224, 119, 108, 136, 118, 441, 187, 464, 509, 288, 755, 173, 
  274, 444, 557, 658, 395, 504, 607, 668, 711, 567, 550, 752, 
  776, 598, 698, 959, 72, 97, 355, 290), PdKeyT = c(-10L, -20L, 
  -22L, -22L, -27L, -26L, -26L, -27L, -22L, -17L, -19L, -19L, 
  -23L, -23L, -5L, -9L, -9L, 54L, 53L, 40L, 60L, 43L, 19L, 
  15L, 15L, 15L, 13L, 8L, 9L, 7L, 7L, 9L, 6L, 8L, 6L, 12L, 
  9L, 4L, 2L, 2L, 3L, 2L, 75L, 43L, 28L, 13L)), row.names = 125:170, class = "data.frame")

library(dplyr)
library(ggplot2)
library(ggcorrplot)
library(GGally)

CorrPoint_LevelvsBands <- round(cor(subset(loopsubset_created[c(19,9:18)])),2)
print(CorrPoint_LevelvsBands)

# Computing correlation matrix with p-values
CorrPoint_LevelvsBands_PVal <- cor_pmat(loopsubset_created[c(19,9:18)])
print(CorrPoint_LevelvsBands_PVal)

print(
  ggpairs(loopsubset_created[c(19,9:18)],
          title = paste("Corr. analysis"),
          lower = list(continuous = wrap("cor",
                                         size = 3)),
          upper = list(
            continuous = wrap("smooth",
                              alpha = 0.3,
                              size = 0.1))
  ) +
    theme(axis.text.x = element_text(angle = 90, hjust = 1, size=8)) +
    theme(axis.text.y = element_text(hjust = 1, size=8))
)
Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294
jaysigg
  • 201
  • 1
  • 7
  • This is just they way `ggpairs` is implemented--nothing special about your data or arguments. The behavior is the same with `GGally::ggpairs(mtcars)`. You could [report it as a bug](https://github.com/ggobi/ggally/issues?q=is%3Aissue+is%3Aopen+ggpairs), but it's not clear to me what a solution is: any other axis label on that upper left plot would be misleading for the plot it's on... maybe a right-hand axis label for the top row? Or label axes for every facet with a plot? – Gregor Thomas Sep 26 '22 at 04:06

0 Answers0