如果我有一個整數向量(或者如果我把它放到一個矩陣中),無論如何可以使用 ggplot 或其他包來繪制熱圖,這些包可以給我每個點作為一個圓圈而不是一個平鋪?
> counts
[1] 1949 1690 1935 2480 1441 1141 2079 1587 517 1028 535 2180 1692 3916 1784
[16] 3028 1911 1329 1759 1478 1080 2835 2187 3230 2932 3527 1538 1489 1493 1170
[31] 3311 4982 4842 4899 1339 3594 2562 1821 1077 1072 4312 3395 3522 1037 3270
[46] 4813 1686 1955 3290 1288 2592 3717 213 2840 3938 3882 1807 1582 2519 2600
[61] 4093 2318 3028 3074 1833 3453 2539 2665 2491 2696 2819 1177 1707 1832 3223
[76] 2366 3742 2648 1594 2112 2239 2840 414 1094 2621 3116 1939 2847 1781 1054
[91] 1098 1977 1061 2441 2367 723 1126 2550 586 515
這樣它看起來像這樣(按 ax 乘以 y 矩陣排列):

uj5u.com熱心網友回復:
如果您希望圓圈無論縮放如何都能觸摸,ggforce::geom_circles可能會有所幫助:
z <- runif(100, 0, 5000)
library(dplyr); library(ggplot2)
data.frame(z = z) %>%
mutate(row = (row_number() - 1) %/% 10 1,
col = (row_number() - 1) %% 10 1) %>%
ggplot()
ggforce::geom_circle(aes(x0 = col, y0 = row, fill = z, r = 0.5))
scale_y_reverse()
scale_fill_gradient(low = "yellow", high = "red", breaks = 1000*(0:6))
guides(fill = guide_colorsteps(barwidth = 0.3, barheight = 17))
coord_equal(clip = "off")
theme_void()

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/321491.html
