Hi!
I'm getting very confused as to why rows seems to be removed when they shouldn't be when I plot them. The y-values range from 1 to 8, but when I create the diagram, it plots from 0 to 10. If I change it to ylim(1-8) I get this error. Why?!
Here's my full data and the plot:
data.frame(
stringsAsFactors = FALSE,
species = c("Acraea issoria",
"Athyma asura","Athyma cama","Athyma orientalis",
"Athyma selenophora","Atrophaneura aidoneus","Bibasis vasutana",
"Byasa crassipes","Byasa polyeuctes","Cethosia biblis",
"Cyrestis thyodamas","Danaus genutia","Delias pasithoe",
"Dichorragia nesimachus","Dodona adonira","Euploea eunice",
"Euploea mulciber","Euthalia iva","Euthalia lubentina",
"Graphium agamemnon","Graphium agetes",
"Graphium chironides","Graphium cloanthus","Graphium doson",
"Graphium leechi","Graphium sarpedon","Hebomoia glaucippe",
"Heliophorus brahma","Hestina assimilis",
"Hypolimnas bolina","Junonia almana","Junonia atlites","Junonia orithya",
"Kaniska canace","Lamproptera curius","Lethe confusa",
"Lethe dura","Lethe sinorix","Lethe verma",
"Melanitis leda","Neope armandii","Neope pulaha",
"Neorina patria","Neptis hylas","Pachliopta aristolochiae",
"Papilio arcturus","Papilio bianor","Papilio demoleus",
"Papilio helenus","Papilio memnon","Papilio nephelus",
"Papilio paris","Papilio polytes","Papilio protenor",
"Parantica sita","Parasarpa dudu","Pieris canidia",
"Pieris rapae","Polyura dolon","Prioneris thestylis",
"Pseudergolis wedah","Stibochiona nicea","Sumalia daraxa",
"Symbrenthia lilaea","Troides aeacus","Vanessa cardui",
"Vanessa indica","Vindula erota","Zemeros flegyas"),
n = c(1,7,7,7,1,7,1,6,7,8,1,
7,7,1,1,1,7,1,3,1,6,2,6,1,7,7,6,1,7,7,
2,4,2,2,2,1,1,2,7,7,1,3,1,7,8,7,7,1,7,
5,2,7,6,7,2,4,6,1,5,1,7,3,7,7,5,1,6,7,
2),
Family = c("Nymphalidae","Nymphalidae",
"Nymphalidae","Nymphalidae","Nymphalidae",
"Papilionidae","Hesperiidae","Papilionidae","Papilionidae",
"Nymphalidae","Nymphalidae","Nymphalidae","Pieridae",
"Nymphalidae","Riodinidae","Nymphalidae","Nymphalidae",
"Nymphalidae","Nymphalidae","Papilionidae","Papilionidae",
"Papilionidae","Papilionidae","Papilionidae",
"Papilionidae","Papilionidae","Pieridae","Lycaenidae",
"Nymphalidae","Nymphalidae","Nymphalidae","Nymphalidae",
"Nymphalidae","Nymphalidae","Papilionidae","Nymphalidae",
"Nymphalidae","Nymphalidae","Nymphalidae","Nymphalidae",
"Nymphalidae","Nymphalidae","Nymphalidae",
"Nymphalidae","Papilionidae","Papilionidae","Papilionidae",
"Papilionidae","Papilionidae","Papilionidae",
"Papilionidae","Papilionidae","Papilionidae","Papilionidae",
"Nymphalidae","Nymphalidae","Pieridae","Pieridae",
"Nymphalidae","Pieridae","Nymphalidae","Nymphalidae",
"Nymphalidae","Nymphalidae","Papilionidae","Nymphalidae",
"Nymphalidae","Nymphalidae","Riodinidae"),
Individuals = c(33,411,293,277,16,103,13,
69,291,1143,13,1425,355,32,11,40,3588,13,26,
15,43,60,116,3,454,152,52,4,637,201,56,111,
59,24,72,15,8,13,123,196,7,40,42,71,2844,107,
1760,7,414,87,45,900,23,2737,289,93,152,51,
71,62,153,51,114,160,47,51,124,170,48),
indi_logged = c(3.49650756146648,
6.01859321449623,5.68017260901707,5.62401750618734,2.77258872223978,
4.63472898822964,2.56494935746154,4.23410650459726,
5.67332326717149,7.04141166379481,2.56494935746154,
7.26192709270275,5.87211778947542,3.46573590279973,
2.39789527279837,3.68887945411394,8.18535022317869,
2.56494935746154,3.25809653802148,2.70805020110221,
3.76120011569356,4.0943445622221,4.75359019110636,1.09861228866811,
6.11809719804135,5.02388052084628,3.95124371858143,
1.38629436111989,6.45676965557216,5.30330490805908,
4.02535169073515,4.70953020131233,4.07753744390572,
3.17805383034795,4.27666611901606,2.70805020110221,
2.07944154167984,2.56494935746154,4.81218435537242,
5.27811465923052,1.94591014905531,3.68887945411394,3.73766961828337,
4.26267987704132,7.95296679092313,4.67282883446191,
7.4730690880322,1.94591014905531,6.02586597382531,
4.46590811865458,3.80666248977032,6.80239476332431,
3.13549421592915,7.91461770904068,5.66642668811243,
4.53259949315326,5.02388052084628,3.93182563272433,
4.26267987704132,4.12713438504509,5.03043792139244,3.93182563272433,
4.7361984483945,5.07517381523383,3.85014760171006,
3.93182563272433,4.82028156560504,5.13579843705026,
3.87120101090789)
)
And here's my plot function:
spx2 <- ggscatter(data_2_mod, x="indi_logged", y="n", add="reg.line", add.params = list(color="blue", fill="lightgray"),
conf.int=TRUE) + ylab("n") + xlab("indi_logged") +
ggtitle(expression(atop(bold("individuals (per species) vs. replicates"), atop(italic("Extracted data"))))) +
theme(plot.title = element_text(color="#993333", size=14, face="bold", hjust = 0.5))
spx2 + stat_cor(method="pearson", label.x =3, label.y = 7)
spx2 + stat_cor(p.accuracy = 0.001, r.accuracy = 0.01, label.x=3, label.y = 9)