我不知道如何在我的泡泡图中设置R,geom_point,ggplot的大小。我的数值变量之一是p-值,最小的气泡是从最小的p-值自动绘制出来的,但我想把它做出来,这样最大的p值就可以用图上最小的气泡大小来表示。

我试过使用p + guides(size= guide_legend(reverse = TRUE)),但这只是改变了传说中气泡大小的顺序。
library(ggplot2)
data(TFRC, package="ggplot2")
TFRC <- read.csv(file.choose(), header = TRUE)
# bubble chart showing position of polymorphisms on gene, the frequency of each of these polymorphisms, where they are prominent on earth, and p-value
TFRCggplot <- ggplot(TFRC, aes(Position, Frequency))+
geom_jitter(aes(col=Geographical.Location, size=p.value))+
labs(subtitle="Frequency of Various Polymorphisms", title="TFRC")
TFRCggplot + guides(size = guide_legend(reverse = TRUE))发布于 2019-07-31 05:10:50
见?scale_size_continuous。
您可以尝试反转范围值:
library(tibble)
library(ggplot2)
tibble(x = 1:5,
y = c(0.001, 0.01, 0.05, 0.1, 1)) %>%
ggplot(aes(x, y)) +
geom_point(aes(size = y)) +
scale_size_continuous(range = c(6, 1))

或者你可以试试trans = "reverse"
tibble(x = 1:5,
y = c(0.001, 0.01, 0.05, 0.1, 1)) %>%
ggplot(aes(x, y)) +
geom_point(aes(size = y)) +
scale_size_continuous(trans = "reverse")

https://stackoverflow.com/questions/57283439
复制相似问题