[英]Create plot with only x axis
I want to create a bubble plot without the y axis, meaning the x axis represents a range between certain values and the size of the bubbles corresponds to a "number" variable.我想创建一个没有 y 轴的气泡 plot,这意味着 x 轴表示特定值之间的范围,气泡的大小对应于“数字”变量。
Since geom_point()
requires ay variable, I created a new
column with only zero values and assigned it to the y axis.由于
geom_point()
需要 ay 变量,我创建了一个只有零值的new
列并将其分配给 y 轴。
ggplot(df, aes(x=range, y=new, size = numberPoints)) +
geom_point(alpha=0.5, shape=19) +
scale_size(range = c(.1, 24)) +
scale_y_continuous(breaks = NULL)
However, it gave the following result (the y axis is too large):但是,它给出了以下结果(y 轴太大):
I only wanted the bubbles above the x axis (without too much space), but I can't find a way to do it.我只想要 x 轴上方的气泡(没有太多空间),但我找不到办法。
You can use coord_fixed
to "reduce" your axis您可以使用
coord_fixed
来“减少”您的轴
library(dplyr)
library(ggplot2)
data.frame(x = c(1,2,3,4), size = c(1,1,4,8)) %>%
ggplot(aes(x=x, y=1, size = size)) +
geom_point(alpha=0.5, shape=19) +
scale_size(range = c(.1, 24)) +
scale_y_continuous(breaks = NULL)+
coord_fixed(6)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.