нет сюжета / очень маленькие заголовки при вызове ggplot geom_tile - PullRequest
0 голосов
/ 06 июня 2019

Я работаю с большим количеством данных в сетке и обычно использую geom_tile для построения графика. Однако, когда я пытаюсь построить свой текущий набор данных, он не работает. Я не уверен, есть ли правила, когда geom_tile () работает или не работает, и какова альтернатива в этих ситуациях.

Вот пример кода:

example <- structure(list(cellNo = c(540L, 542L, 544L, 545L, 547L, 549L, 
554L, 555L, 557L, 559L, 561L, 563L, 564L, 565L, 566L, 567L, 591L, 
593L, 595L, 597L, 599L, 600L, 602L, 607L, 609L, 610L, 612L, 614L, 
616L, 618L, 620L, 643L, 645L, 647L, 648L, 650L, 652L, 654L, 656L, 
659L, 661L, 663L, 665L, 667L, 668L, 670L, 697L, 699L, 701L, 703L, 
705L, 707L, 708L, 710L, 714L, 715L, 717L, 719L, 721L, 756L, 758L, 
759L, 760L, 761L, 762L, 763L, 764L, 766L, 768L, 770L, 772L, 812L, 
813L, 814L, 816L, 817L, 818L, 819L, 820L, 821L, 822L, 823L, 871L, 
872L, 873L, 874L, 875L, 876L, 877L, 878L, 879L, 880L, 881L, 882L, 
883L, 884L, 932L, 933L, 934L, 935L, 936L, 937L, 938L, 939L, 940L, 
941L, 942L, 943L, 944L, 945L, 946L, 992L, 993L, 994L, 995L, 996L, 
997L, 998L, 999L, 1000L, 1001L, 1002L, 1003L, 1004L, 1005L, 1006L, 
1049L, 1050L, 1051L, 1052L, 1053L, 1054L, 1055L, 1056L, 1057L, 
1058L, 1059L, 1060L, 1061L, 1062L, 1063L, 1104L, 1105L, 1106L, 
1107L, 1108L, 1109L, 1110L, 1111L, 1112L, 1113L, 1114L, 1115L, 
1116L, 1117L, 1118L), x = c(-3.9255, -3.9209, -3.9162, -3.9116, 
-3.9071, -3.9025, -3.8847, -3.8803, -3.8759, -3.8716, -3.8672, 
-3.863, -3.8587, -3.8544, -3.8502, -3.846, -3.7499, -3.7457, 
-3.7415, -3.7373, -3.7331, -3.729, -3.7249, -3.7088, -3.7048, 
-3.7009, -3.6969, -3.693, -3.6892, -3.6853, -3.6815, -3.5742, 
-3.5704, -3.5667, -3.5629, -3.5592, -3.5555, -3.5518, -3.5481, 
-3.5373, -3.5337, -3.5301, -3.5266, -3.5231, -3.5196, -3.5161, 
-3.3986, -3.3952, -3.3918, -3.3885, -3.3852, -3.3819, -3.3786, 
-3.3754, -3.3657, -3.3625, -3.3594, -3.3562, -3.3531, -3.2229, 
-3.2199, -3.217, -3.2141, -3.2112, -3.2083, -3.2054, -3.2026, 
-3.1941, -3.1914, -3.1886, -3.1859, -3.0472, -3.0446, -3.0421, 
-3.0396, -3.0371, -3.0347, -3.0322, -3.0226, -3.0202, -3.0178, 
-3.0155, -2.8714, -2.8693, -2.8672, -2.8652, -2.8631, -2.861, 
-2.857, -2.855, -2.853, -2.851, -2.849, -2.847, -2.8451, -2.8431, 
-2.6957, -2.694, -2.6924, -2.6907, -2.689, -2.6874, -2.6858, 
-2.6842, -2.6825, -2.6809, -2.6794, -2.6778, -2.6762, -2.6746, 
-2.6731, -2.52, -2.5187, -2.5175, -2.5162, -2.515, -2.5138, -2.5125, 
-2.5113, -2.5101, -2.5089, -2.5077, -2.5066, -2.5054, -2.5042, 
-2.5031, -2.3442, -2.3434, -2.3425, -2.3417, -2.3409, -2.3401, 
-2.3393, -2.3385, -2.3377, -2.3369, -2.3361, -2.3353, -2.3346, 
-2.3338, -2.333, -2.1684, -2.168, -2.1676, -2.1672, -2.1668, 
-2.1664, -2.166, -2.1656, -2.1653, -2.1649, -2.1645, -2.1641, 
-2.1637, -2.1633, -2.163), y = c(52.2266, 52.1187, 52.0109, 51.9031, 
51.7952, 51.6874, 51.256, 51.1481, 51.0403, 50.9324, 50.8245, 
50.7167, 50.6088, 50.5009, 50.393, 50.2852, 52.2293, 52.1215, 
52.0136, 51.9058, 51.7979, 51.6901, 51.5822, 51.1507, 51.0429, 
50.935, 50.8271, 50.7193, 50.6114, 50.5035, 50.3956, 52.2318, 
52.1239, 52.0161, 51.9082, 51.8004, 51.6925, 51.5846, 51.4767, 
51.1531, 51.0452, 50.9374, 50.8295, 50.7216, 50.6137, 50.5058, 
52.234, 52.1261, 52.0183, 51.9104, 51.8025, 51.6947, 51.5868, 
51.4789, 51.1553, 51.0474, 50.9395, 50.8316, 50.7237, 52.236, 
52.1281, 52.0202, 51.9123, 51.8044, 51.6966, 51.5887, 51.4808, 
51.1571, 51.0492, 50.9413, 50.8334, 52.2376, 52.1298, 52.0219, 
51.914, 51.8061, 51.6982, 51.5903, 51.1588, 51.0509, 50.943, 
50.835, 52.2391, 52.1312, 52.0233, 51.9154, 51.8075, 51.6996, 
51.4838, 51.3759, 51.268, 51.1601, 51.0522, 50.9443, 50.8364, 
50.7285, 52.2402, 52.1323, 52.0245, 51.9166, 51.8087, 51.7008, 
51.5929, 51.485, 51.3771, 51.2692, 51.1613, 51.0533, 50.9454, 
50.8375, 50.7296, 52.2411, 52.1333, 52.0254, 51.9175, 51.8096, 
51.7017, 51.5938, 51.4859, 51.3779, 51.27, 51.1621, 51.0542, 
50.9463, 50.8384, 50.7305, 52.2418, 52.1339, 52.026, 51.9181, 
51.8102, 51.7023, 51.5944, 51.4865, 51.3786, 51.2707, 51.1627, 
51.0548, 50.9469, 50.839, 50.7311, 52.2422, 52.1343, 52.0264, 
51.9185, 51.8106, 51.7027, 51.5948, 51.4868, 51.3789, 51.271, 
51.1631, 51.0552, 50.9473, 50.8394, 50.7314)), class = c("tbl_df", 
"tbl", "data.frame"), row.names = c(NA, -156L))

example %>%
  ggplot(aes(x = x, y = y)) +
  geom_tile(fill = "blue", size = 10)

example %>%
  ggplot(aes(x = x, y = y)) +
  geom_point()

enter image description here

1 Ответ

0 голосов
/ 07 июня 2019

Как уже говорили другие, проблема заключается в нерегулярном расстоянии между точками.geom_tile() ищет наименее общий знаменатель.Я бы попробовал другой метод, чтобы увидеть плотность.С большим количеством очков вы также можете попробовать geom_hex()

example %>%
  ggplot(aes(x = x, y = y)) +
  stat_density_2d(aes(fill = ..density..), geom = "raster", contour = FALSE)

enter image description here

...