首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有没有办法改变R中ggplot2 (geom_point)中的大小值范围?

有没有办法改变R中ggplot2 (geom_point)中的大小值范围?
EN

Stack Overflow用户
提问于 2019-07-31 04:55:27
回答 1查看 1.1K关注 0票数 1

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

我试过使用p + guides(size= guide_legend(reverse = TRUE)),但这只是改变了传说中气泡大小的顺序。

代码语言:javascript
复制
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))
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-31 05:10:50

?scale_size_continuous

您可以尝试反转范围值:

代码语言:javascript
复制
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"

代码语言:javascript
复制
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")

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57283439

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档