I am having trouble formatting my legend with my scale_size_area()
component. I would like the 0% abundance to be the tiny pinpoints (created by scale_size_area()
) rather than having any size (created by my scale_size_continuous()
) since it seems misleading. Thank you!
p3 <- ggplot(data_melt, aes(x=index, y=variable, fill = time)) +
geom_point(aes(size = value),shape = 21) +
scale_size_area() +
scale_size_continuous(name= "Percent\nAbundance", breaks = c(0,2,4,6),
labels = c("0%","20%","40%","60%")) +
scale_fill_discrete(name = "Sampling\nEffort", labels = c("Summer","Winter")) +
xlab("") +
ylab("Taxonomy") +
theme_linedraw() +
scale_fill_manual(values = c("mediumseagreen","cornflowerblue")) +
scale_color_manual(values = c("mediumseagreen","cornflowerblue")) +
theme(legend.position = "bottom", legend.box = "horizontal", legend.direction = "horizontal",
panel.background = element_blank()) +
theme(axis.text.x = element_text(angle=45, hjust = 1)) +
theme(plot.title = element_text(size = 8)) +
theme(aspect.ratio = 1/2)
print(p3)
Reproducibility:
data_melt <- structure(list(system = structure(c(2L, 2L, 2L, 2L, 2L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 6L, 6L, 3L, 4L, 4L, 4L, 4L, 5L, 2L, 2L, 2L,
2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 6L, 6L, 3L, 4L, 4L, 4L, 4L,
5L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 6L, 6L, 3L,
4L, 4L, 4L, 4L, 5L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L,
2L, 6L, 6L, 3L, 4L, 4L, 4L, 4L, 5L, 2L, 2L, 2L, 2L, 2L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 6L, 6L, 3L, 4L, 4L, 4L, 4L, 5L, 2L, 2L, 2L,
2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 6L, 6L, 3L, 4L, 4L, 4L, 4L,
5L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 6L,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3L, 4L, 5L, 7L, 8L, 9L, 10L, 11L, 12L,
6L, 19L, 20L, 13L, 14L, 15L, 16L, 17L, 18L, 1L, 2L, 3L, 4L, 5L,
7L, 8L, 9L, 10L, 11L, 12L, 6L, 19L, 20L, 13L, 14L, 15L, 16L,
17L, 18L, 1L, 2L, 3L, 4L, 5L, 7L, 8L, 9L, 10L, 11L, 12L, 6L,
19L, 20L, 13L, 14L, 15L, 16L, 17L, 18L, 1L, 2L, 3L, 4L, 5L, 7L,
8L, 9L, 10L, 11L, 12L, 6L, 19L, 20L, 13L, 14L, 15L, 16L, 17L,
18L, 1L, 2L, 3L, 4L, 5L, 7L, 8L, 9L, 10L, 11L, 12L, 6L, 19L,
20L, 13L, 14L, 15L, 16L, 17L, 18L, 1L, 2L, 3L, 4L, 5L, 7L, 8L,
9L, 10L, 11L, 12L, 6L, 19L, 20L, 13L, 14L, 15L, 16L, 17L, 18L,
1L, 2L, 3L, 4L, 5L, 7L, 8L, 9L, 10L, 11L, 12L, 6L, 19L, 20L,
13L, 14L, 15L, 16L, 17L, 18L, 1L, 2L, 3L, 4L, 5L, 7L, 8L, 9L,
10L, 11L, 12L, 6L, 19L, 20L, 13L, 14L, 15L, 16L, 17L, 18L, 1L,
2L, 3L, 4L, 5L, 7L, 8L, 9L, 10L, 11L, 12L, 6L, 19L, 20L, 13L,
14L, 15L, 16L, 17L, 18L, 1L, 2L, 3L, 4L, 5L, 7L, 8L, 9L, 10L,
11L, 12L, 6L, 19L, 20L, 13L, 14L, 15L, 16L, 17L, 18L, 1L, 2L,
3L, 4L, 5L, 7L, 8L, 9L, 10L, 11L, 12L, 6L, 19L, 20L, 13L, 14L,
15L, 16L, 17L, 18L, 1L, 2L, 3L, 4L, 5L, 7L, 8L, 9L, 10L, 11L,
12L, 6L, 19L, 20L, 13L, 14L, 15L, 16L, 17L, 18L, 1L, 2L, 3L,
4L, 5L, 7L, 8L, 9L, 10L, 11L, 12L, 6L, 19L, 20L, 13L, 14L, 15L,
16L, 17L, 18L, 1L, 2L, 3L, 4L, 5L, 7L, 8L, 9L, 10L, 11L, 12L,
6L, 19L, 20L, 13L, 14L, 15L, 16L, 17L, 18L), .Label = c("CC",
"LC1", "LC2", "NFTC1", "NFTC2", "SFTC", "Saup1", "Saup2", "Saup3",
"Saup4", "Saup5", "Saup6", "BOSS1", "Deployment1", "Deployment2",
"Deployment3", "Deployment4", "BOSS2", "Retrieval1", "Retrieval2"
), class = "factor"), variable = c("Gammaproteobacteria", "Gammaproteobacteria",
"Gammaproteobacteria", "Gammaproteobacteria", "Gammaproteobacteria",
"Gammaproteobacteria", "Gammaproteobacteria", "Gammaproteobacteria",
"Gammaproteobacteria", "Gammaproteobacteria", "Gammaproteobacteria",
"Gammaproteobacteria", "Gammaproteobacteria", "Gammaproteobacteria",
"Gammaproteobacteria", "Gammaproteobacteria", "Gammaproteobacteria",
"Gammaproteobacteria", "Gammaproteobacteria", "Gammaproteobacteria",
"Bacteroidia", "Bacteroidia", "Bacteroidia", "Bacteroidia", "Bacteroidia",
"Bacteroidia", "Bacteroidia", "Bacteroidia", "Bacteroidia", "Bacteroidia",
"Bacteroidia", "Bacteroidia", "Bacteroidia", "Bacteroidia", "Bacteroidia",
"Bacteroidia", "Bacteroidia", "Bacteroidia", "Bacteroidia", "Bacteroidia",
"Oxyphotobacteria", "Oxyphotobacteria", "Oxyphotobacteria", "Oxyphotobacteria",
"Oxyphotobacteria", "Oxyphotobacteria", "Oxyphotobacteria", "Oxyphotobacteria",
"Oxyphotobacteria", "Oxyphotobacteria", "Oxyphotobacteria", "Oxyphotobacteria",
"Oxyphotobacteria", "Oxyphotobacteria", "Oxyphotobacteria", "Oxyphotobacteria",
"Oxyphotobacteria", "Oxyphotobacteria", "Oxyphotobacteria", "Oxyphotobacteria",
"Alphaproteobacteria", "Alphaproteobacteria", "Alphaproteobacteria",
"Alphaproteobacteria", "Alphaproteobacteria", "Alphaproteobacteria",
"Alphaproteobacteria", "Alphaproteobacteria", "Alphaproteobacteria",
"Alphaproteobacteria", "Alphaproteobacteria", "Alphaproteobacteria",
"Alphaproteobacteria", "Alphaproteobacteria", "Alphaproteobacteria",
"Alphaproteobacteria", "Alphaproteobacteria", "Alphaproteobacteria",
"Alphaproteobacteria", "Alphaproteobacteria", "Deltaproteobacteria",
"Deltaproteobacteria", "Deltaproteobacteria", "Deltaproteobacteria",
"Deltaproteobacteria", "Deltaproteobacteria", "Deltaproteobacteria",
"Deltaproteobacteria", "Deltaproteobacteria", "Deltaproteobacteria",
"Deltaproteobacteria", "Deltaproteobacteria", "Deltaproteobacteria",
"Deltaproteobacteria", "Deltaproteobacteria", "Deltaproteobacteria",
"Deltaproteobacteria", "Deltaproteobacteria", "Deltaproteobacteria",
"Deltaproteobacteria", "Verrucomicrobiae", "Verrucomicrobiae",
"Verrucomicrobiae", "Verrucomicrobiae", "Verrucomicrobiae", "Verrucomicrobiae",
"Verrucomicrobiae", "Verrucomicrobiae", "Verrucomicrobiae", "Verrucomicrobiae",
"Verrucomicrobiae", "Verrucomicrobiae", "Verrucomicrobiae", "Verrucomicrobiae",
"Verrucomicrobiae", "Verrucomicrobiae", "Verrucomicrobiae", "Verrucomicrobiae",
"Verrucomicrobiae", "Verrucomicrobiae", "Actinobacteria", "Actinobacteria",
"Actinobacteria", "Actinobacteria", "Actinobacteria", "Actinobacteria",
"Actinobacteria", "Actinobacteria", "Actinobacteria", "Actinobacteria",
"Actinobacteria", "Actinobacteria", "Actinobacteria", "Actinobacteria",
"Actinobacteria", "Actinobacteria", "Actinobacteria", "Actinobacteria",
"Actinobacteria", "Actinobacteria", "Methanomicrobia", "Methanomicrobia",
"Methanomicrobia", "Methanomicrobia", "Methanomicrobia", "Methanomicrobia",
"Methanomicrobia", "Methanomicrobia", "Methanomicrobia", "Methanomicrobia",
"Methanomicrobia", "Methanomicrobia", "Methanomicrobia", "Methanomicrobia",
"Methanomicrobia", "Methanomicrobia", "Methanomicrobia", "Methanomicrobia",
"Methanomicrobia", "Methanomicrobia", "Parcubacteria", "Parcubacteria",
"Parcubacteria", "Parcubacteria", "Parcubacteria", "Parcubacteria",
"Parcubacteria", "Parcubacteria", "Parcubacteria", "Parcubacteria",
"Parcubacteria", "Parcubacteria", "Parcubacteria", "Parcubacteria",
"Parcubacteria", "Parcubacteria", "Parcubacteria", "Parcubacteria",
"Parcubacteria", "Parcubacteria", "Clostridia", "Clostridia",
"Clostridia", "Clostridia", "Clostridia", "Clostridia", "Clostridia",
"Clostridia", "Clostridia", "Clostridia", "Clostridia", "Clostridia",
"Clostridia", "Clostridia", "Clostridia", "Clostridia", "Clostridia",
"Clostridia", "Clostridia", "Clostridia", "Bacilli", "Bacilli",
"Bacilli", "Bacilli", "Bacilli", "Bacilli", "Bacilli", "Bacilli",
"Bacilli", "Bacilli", "Bacilli", "Bacilli", "Bacilli", "Bacilli",
"Bacilli", "Bacilli", "Bacilli", "Bacilli", "Bacilli", "Bacilli",
"Planctomycetacia", "Planctomycetacia", "Planctomycetacia", "Planctomycetacia",
"Planctomycetacia", "Planctomycetacia", "Planctomycetacia", "Planctomycetacia",
"Planctomycetacia", "Planctomycetacia", "Planctomycetacia", "Planctomycetacia",
"Planctomycetacia", "Planctomycetacia", "Planctomycetacia", "Planctomycetacia",
"Planctomycetacia", "Planctomycetacia", "Planctomycetacia", "Planctomycetacia",
"Woesearchaeia", "Woesearchaeia", "Woesearchaeia", "Woesearchaeia",
"Woesearchaeia", "Woesearchaeia", "Woesearchaeia", "Woesearchaeia",
"Woesearchaeia", "Woesearchaeia", "Woesearchaeia", "Woesearchaeia",
"Woesearchaeia", "Woesearchaeia", "Woesearchaeia", "Woesearchaeia",
"Woesearchaeia", "Woesearchaeia", "Woesearchaeia", "Woesearchaeia",
"Fibrobacteria", "Fibrobacteria", "Fibrobacteria", "Fibrobacteria",
"Fibrobacteria", "Fibrobacteria", "Fibrobacteria", "Fibrobacteria",
"Fibrobacteria", "Fibrobacteria", "Fibrobacteria", "Fibrobacteria",
"Fibrobacteria", "Fibrobacteria", "Fibrobacteria", "Fibrobacteria",
"Fibrobacteria", "Fibrobacteria", "Fibrobacteria", "Fibrobacteria",
"Gemmatimonadetes", "Gemmatimonadetes", "Gemmatimonadetes", "Gemmatimonadetes",
"Gemmatimonadetes", "Gemmatimonadetes", "Gemmatimonadetes", "Gemmatimonadetes",
"Gemmatimonadetes", "Gemmatimonadetes", "Gemmatimonadetes", "Gemmatimonadetes",
"Gemmatimonadetes", "Gemmatimonadetes", "Gemmatimonadetes", "Gemmatimonadetes",
"Gemmatimonadetes", "Gemmatimonadetes", "Gemmatimonadetes", "Gemmatimonadetes"
), value = c(0.476106048997322, 0.830003735903297, 0.478638864791961,
0.545188599796108, 0.891044596554104, 1.28806347236381, 0.412659013341607,
0.442926162087547, 1.89068367030337, 0.188124893146834, 0.433174821278186,
0.50953921748656, 0.276266882800281, 0.0242517112336713, 0.226687013620217,
0.00151968947678358, 0.188948058280091, 0.22174802282067, 0.158427627954688,
0.515997897762891, 0.24309339904279, 0.456688622470739, 0.323532199213382,
0.790645879732739, 0.561294602663128, 1.48130597545373, 0.769321897360565,
0.739823721745723, 2.76169265033408, 0.126166895702033, 0.561413069231863,
0.608325830450647, 0.370089560725963, 0.0485712931810643, 0.00770032696772971,
0, 0.138842818556603, 0.00035539970620291, 0, 0.0111358574610245,
0.969546030497662, 0.0591310933426545, 1.23563595053961, 1.20607040386828,
1.36642344271129, 0.337600675783924, 1.04032857080439, 1.25005461615764,
0.704184325890972, 0.0272352572785133, 0.462999373734726, 1.23650980906191,
0.0276721865396659, 0.000582572348203492, 0.00436929261152619,
0.000436929261152619, 0.0656850322599438, 0.00509750804678056,
0.000436929261152619, 0, 0.543384391618563, 0.427480569065043,
0.635652924867051, 0.140675423844371, 0.632016726512431, 1.02904413435753,
0.619062769874097, 0.603836189264124, 2.12535793827553, 0.289532293986637,
0.694286623335303, 0.639970910413163, 1.00972683059861, 0.255215672014908,
0.0211354029362302, 0.000681787191491296, 0.307940548156902,
0.00795418390073178, 0.00181809917731012, 0.0152265806099723,
0.517491852840708, 0.0852016176528329, 1.17083513290667, 0.00510424437551533,
0.195139188817778, 1.67026581334171, 0.540264635439161, 0.508068632455142,
2.92787310063214, 0.228120460167262, 1.08406297852291, 0.434646040284267,
0.351407593545094, 0.00117790254819585, 0.0416192233695866, 0,
0.22969099689819, 0.000785268365463897, 0, 0.00824531783737092,
0.669516527184057, 0.38713950267927, 1.20296224938286, 0.00541874887109399,
0.0662291528689265, 1.22162682882774, 0.897103979770004, 0.801372749714011,
2.29694743813595, 0.338370762839424, 0.762237341200554, 1.01270395568668,
0.212535372388464, 0, 0.00602083207899332, 0.00240833283159733,
0.11740622554037, 0, 0, 0, 0.585285805451728, 1.48965265748929,
0.0774911113137022, 1.35655027805634, 0.139484000364664, 1.25809098368128,
0.583462485185523, 0.660041936366123, 1.27358920594402, 0.412070380162275,
0.298112863524478, 0.156805542893609, 0.803172577263196, 0.416628680827787,
0.0127632418634333, 0.00546996079861428, 0.416628680827787, 0.033731424924788,
0.00820494119792141, 0.0127632418634333, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0.0138257343001106, 0.000614477080004916, 0, 0.0119823030600959,
0.128118471181025, 2.07939043873664, 0.000921715620007374, 0.00491581664003933,
1.19454344352956, 0.856888288066855, 5.70879931178567, 0.976924139836949,
0.0497443692137626, 0.801437059555064, 0.00276357606743126, 0.0138178803371563,
1.63327345585187, 0.79314633135277, 0.80281884758878, 2.69310487771176,
0.374464557136935, 0.695039380958961, 0.476716871631892, 0.266685090507116,
0, 0, 0, 0.397954953710101, 0.00414536410114688, 0, 0.0179632444383032,
0.136315973435862, 0.0227193289059769, 0.0926249563089829, 0.012233484795526,
0, 1.48025166025865, 0.470115344285215, 0.290108353722475, 2.49737853897239,
0.270884306186648, 0.223698007689619, 0.700803914715135, 3.09507165326809,
0.0104858441104509, 0.00524292205522545, 0.0034952813701503,
0.64837469416288, 0.0279622509612024, 0.00699056274030059, 0.00524292205522545,
0.118838028169014, 0.0132042253521127, 0.0902288732394366, 0.0154049295774648,
0.00880281690140845, 0.492957746478873, 1.39084507042254, 0.0770246478873239,
0.506161971830986, 0.352112676056338, 0.129841549295775, 0.305897887323944,
6.07174295774648, 0.0374119718309859, 0.0220070422535211, 0,
0.209066901408451, 0.0990316901408451, 0.0110035211267606, 0.0484154929577465,
1.12915129151292, 0.357933579335793, 1.07011070110701, 0, 0.243542435424354,
0.664206642066421, 0.287822878228782, 0.642066420664207, 1.92250922509225,
1.20664206642066, 0.586715867158672, 0.760147601476015, 0.512915129151291,
0, 0.247232472324723, 0, 0.335793357933579, 0.033210332103321,
0, 0, 0.0332565873624968, 0, 0.273727295983628, 0, 0, 2.49680225121514,
0.470708621130724, 0.381171655154771, 4.60475825019186, 1.01560501407009,
0.237912509593246, 0.153491941673062, 0.214888718342287, 0, 0.0153491941673062,
0, 0.0869787669480686, 0, 0, 0.0153491941673062, 0.400183992640294,
0, 2.34130634774609, 0, 0, 1.06255749770009, 0.94296228150874,
0.570377184912604, 2.5114995400184, 0.216191352345906, 0.745170193192272,
0.16099356025759, 0.915363385464581, 0, 0, 0, 0.119595216191352,
0, 0, 0.0137994480220791, 0.938628158844765, 0.391095066185319,
1.00481347773767, 0, 1.43200962695548, 0.673886883273165, 0.577617328519856,
0.553549939831528, 1.44404332129964, 1.01083032490975, 1.22141997593261,
0.649819494584837, 0.0240673886883273, 0.0180505415162455, 0.0421179302045728,
0, 0.0180505415162455, 0, 0, 0)), row.names = c(NA, -300L), class = "data.frame")