首页 > 解决方案 > 指标物种图(带分类轴的气泡图)

问题描述

ggplot2/R 的新手,所以我非常感谢有人为Species跨不同站点NorthSouthEastWestNorth.eastNorthwestSouth.westSouth.east(X) 的两个分类轴 (Y) 创建气泡图。此处列出的值是与地点/物种相关的指标值。另外-如何确定值范围=气泡的大小?例如。值 =0.8-0.9 = 最大尺寸..

样本数据

structure(list(Species = c(13359L, 12867L, 11646L, 13214L, 11413L, 
3413L, 13249L, 11374L, 13267L, 2059L, 12941L, 13123L, 1904L, 
13252L, 12915L, 12749L, 11577L, 995L), North = c(0.94, 0, 0.9, 
0, 0.88, 0.87, 0, 0, 0.86, 0, 0.84, 0.83, 0.83, 0, 0, 0.82, 0.82, 
0.81), South = c(0, 0.92, 0.9, 0, 0.88, 0, 0.87, 0.87, 0.86, 
0.86, 0.84, 0.83, 0, 0.82, 0, 0.82, 0.82, 0), West = c(0, 0.92, 
0.9, 0, 0.88, 0.87, 0.87, 0.87, 0.86, 0.86, 0.84, 0, 0.83, 0.82, 
0, 0.82, 0.82, 0), East = c(0, 0.92, 0.9, 0, 0, 0.87, 0.87, 0.87, 
0, 0.86, 0.84, 0, 0, 0.82, 0, 0.82, 0.82, 0), North.east = c(0, 
0.92, 0.9, 0, 0.88, 0.87, 0.87, 0.87, 0.86, 0.86, 0, 0.83, 0, 
0.82, 0, 0, 0.82, 0.81), Northwest = c(0, 0, 0, 0.88, 0, 0.87, 
0.87, 0.87, 0, 0.86, 0.84, 0, 0, 0.82, 0, 0, 0, 0), South.west = c(0, 
0.92, 0.9, 0.88, 0.88, 0, 0.87, 0, 0.86, 0.86, 0.84, 0.83, 0, 
0, 0, 0.82, 0.82, 0), South.east = c(0, 0.92, 0.9, 0, 0.88, 0, 
0, 0.87, 0.86, 0, 0.84, 0.83, 0.83, 0, 0, 0.82, 0.82, 0)), class = "data.frame", row.names = c(NA, 
-18L))

谢谢 !!!

标签: rggplot2plot

解决方案


你的意思是这样的吗?

df %>%
    gather(Direction, Value, -Species) %>%
    mutate(
        Species = as.factor(Species),
        Orientation = as.factor(Direction)) %>%
    ggplot(aes(Direction, Species)) +
    geom_point(aes(size = Value))

在此处输入图像描述

要设置范围,请查看scale_size和。scale_radiusscale_size_area


推荐阅读