简体   繁体   English

Geom_dotplot,y 轴显示计数

[英]Geom_dotplot, y-axis showing counts

I'm trying to plot a dotplot using geom_dotplot in which each dot represents an observation of my data set.我正在尝试 plot 使用 geom_dotplot 的点图,其中每个点代表对我的数据集的观察。 Therefore, the y-axis shouldn't represent density but actual counts.因此,y 轴不应代表密度,而应代表实际计数。 I'm aware of this thread which revolves around the same topic.我知道这个主题围绕同一主题。 However, I haven't managed to solve my issue following the same methodology.但是,我没有设法按照相同的方法解决我的问题。

df <- data.frame(x = sample(1:500, size = 150, replace = TRUE))

ggplot(df, aes(x)) +
  geom_dotplot(method = 'histodot', binwidth = 1)

And I obtain the following graph我得到下图在此处输入图像描述 , I want to obtain one similar to this one , 我想得到一个和这个相似的一 where I can manipulate dots' size, space between, etc.我可以在其中操纵点的大小、间距等。

Thanks in advance提前致谢

You can modify the binwidth argument to cause the points to stack.您可以修改binwidth参数以使点堆叠。 For example,例如,

df %>%
  ggplot(aes(x = x)) +
  geom_dotplot(method = "histodot", binwidth = 20)

在此处输入图像描述

There is a dotsize argument that can be used to modify the size of the dot.有一个dotsize参数可用于修改点的大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM