ggplot将数据集随机化 我不明白,让我们考虑下面的DATABATE: mt=data.table( "index" = 1:10, "matches" = rep(0,10) ) > mt index matches 1: 1 0 2: 2 0 3: 3 0 4: 4 0 5: 5 0 6: 6 0 7: 7 0 8: 8 0 9: 9 0 10: 10 0

ggplot将数据集随机化 我不明白,让我们考虑下面的DATABATE: mt=data.table( "index" = 1:10, "matches" = rep(0,10) ) > mt index matches 1: 1 0 2: 2 0 3: 3 0 4: 4 0 5: 5 0 6: 6 0 7: 7 0 8: 8 0 9: 9 0 10: 10 0,r,ggplot2,R,Ggplot2,使用ggplot绘制它似乎会随机化真实值周围的数据: ggplot(data = mt, aes(x=index, y=matches)) + geom_jitter() + scale_x_discrete() 每次我重新绘制ggplot时,ggplot都会发生变化,而plot会给出正确的图形: plot(x=mt$index, y=mt$matches) 这一切都是关于…看?几何抖动 如果要复制基本R图,在ggplot中绘制此图的正确方法是使用geom_点geom_抖动,通常在过

使用ggplot绘制它似乎会随机化真实值周围的数据:

ggplot(data = mt, aes(x=index, y=matches)) + geom_jitter() +    scale_x_discrete() 
每次我重新绘制ggplot时,ggplot都会发生变化,而plot会给出正确的图形:

plot(x=mt$index, y=mt$matches)
这一切都是关于…

看?几何抖动

如果要复制基本R图,在ggplot中绘制此图的正确方法是使用geom_点geom_抖动,通常在过度绘制的情况下使用

ggplot(data = mt, aes(x=index, y=matches)) + 
  geom_point() + 
  scale_x_discrete() 

嗯。。。你用的是几何抖动。。。为什么不是geom_point呢?所以我在我的绘图中添加了一些抖动。为什么我的绘图中会出现抖动如果将来出于某种原因,您希望使用geom_抖动并具有可复制的绘图,请先设置一个种子。。。。。。