R:ggplot2 stat_bindot 圆/圆点的替代方案 - 产生错误
R: ggplot2 stat_bindot alternative for circle / round points - error produced
我目前正在使用以下代码在热图上显示矩形图:
stat_bin2d(bins = 19, aes(fill = after_stat(density))) +
出现以下错误:could not find function "stat_bindot"
我用谷歌搜索了这个问题,发现可能是该功能在最新版本中被删除了。
我还能如何将点绘制为 圆 而不是矩形?
示例代码:
数据集是要绘制的 X 和 Y 坐标列表(在单独的列中)。
library(ggplot2)
ggplot(data = my.project_data, aes(x = CoordX,y = CoordY)) +
sstat_bin2d(bins = 19, aes(fill = after_stat(density))) +
scale_fill_gradient(name = "Percent",
low = "#DDDDDD",
high = "#000000",
labels = scales::percent)
如果你想把类似方块的显示改为圆形,你可以把geom
参数改为stat_bin2d()
。下面是标准数据集的示例:
library(ggplot2)
ggplot(data = faithful, aes(x = eruptions, y = waiting)) +
stat_bin2d(bins = 19, aes(colour = after_stat(density),
fill = NULL),
geom = "point", size = 5) +
scale_colour_gradient(name = "Percent",
low = "#DDDDDD",
high = "#000000",
labels = scales::percent)
由 reprex package (v1.0.0)
于 2021-04-23 创建
我目前正在使用以下代码在热图上显示矩形图:
stat_bin2d(bins = 19, aes(fill = after_stat(density))) +
出现以下错误:could not find function "stat_bindot"
我用谷歌搜索了这个问题,发现可能是该功能在最新版本中被删除了。
我还能如何将点绘制为 圆 而不是矩形?
示例代码:
数据集是要绘制的 X 和 Y 坐标列表(在单独的列中)。
library(ggplot2)
ggplot(data = my.project_data, aes(x = CoordX,y = CoordY)) +
sstat_bin2d(bins = 19, aes(fill = after_stat(density))) +
scale_fill_gradient(name = "Percent",
low = "#DDDDDD",
high = "#000000",
labels = scales::percent)
如果你想把类似方块的显示改为圆形,你可以把geom
参数改为stat_bin2d()
。下面是标准数据集的示例:
library(ggplot2)
ggplot(data = faithful, aes(x = eruptions, y = waiting)) +
stat_bin2d(bins = 19, aes(colour = after_stat(density),
fill = NULL),
geom = "point", size = 5) +
scale_colour_gradient(name = "Percent",
low = "#DDDDDD",
high = "#000000",
labels = scales::percent)
由 reprex package (v1.0.0)
于 2021-04-23 创建