From 73fd7036fa6a9f55ea4a157fef5da37fcb2e6781 Mon Sep 17 00:00:00 2001 From: iara <123iamela@gmail.com> Date: Wed, 14 Apr 2021 17:35:20 -0300 Subject: [PATCH] Organizing and cleaning plots for publishing. --- plots.Rmd | 460 +++++------------------------------------------------- 1 file changed, 41 insertions(+), 419 deletions(-) diff --git a/plots.Rmd b/plots.Rmd index a554028..afad82e 100644 --- a/plots.Rmd +++ b/plots.Rmd @@ -1,8 +1,6 @@ --- -title: "Plots" -author: "Iara" -date: "23 de julio de 2020" -output: html_document +title: "plots" +author: "Iara Diamela Rodriguez" editor_options: chunk_output_type: console --- @@ -14,29 +12,31 @@ knitr::opts_chunk$set(echo = TRUE) load(".RData") require(igraph) -require(dplyr) +require(NetIndices) +require(multiweb) + require(ggplot2) + +require(dplyr) require(knitr) require(devtools) -require(multiweb) require(cowplot) -require(NetIndices) + # Typography require(extrafont) -#font_import() -#loadfonts() +font_import() +loadfonts() loadfonts(device="win") # Color palette -#colnet1 <- c("#833f8f", "#ccb7d5","#a8d9c3", "#088a4f") -colnet <- c("#024828","#066e3f","#088a4f","#51b487","#85caab","#a8d9c3", #VERDE +oscuro- - "#ffffff", - "#40004b","#683272","#833f8f","#9970ab","#b79ac4","#ccb7d5") #VIOLETA +oscuro- +colnet <- c("#024828","#066e3f","#088a4f","#51b487","#85caab","#a8d9c3", #green +dark- + "#ffffff", #white + "#40004b","#683272","#833f8f","#9970ab","#b79ac4","#ccb7d5") #purple +dark- -# Plots theme +# Plots' theme theme_new <- theme_minimal() + theme(axis.title.x=element_text(size=18, face="bold", family="Lato", margin=margin(t=8, r=0, b=0, l=0)), @@ -54,131 +54,9 @@ theme_new <- theme_minimal() + ``` -### Plot food webs ### -```{r plotFW, echo=FALSE, message=FALSE} - -#---- Plot fw by TL and species colored by topological role - -ptl <- function (g, topoFrame, vertexLabel = FALSE, vertexSizeFactor = 5, modules = FALSE, lMat = NULL, bpal = NULL, maxTL = NULL, edge.width = NULL, ...) - { - deg <- degree(g, mode = "all") - V(g)$size <- log10(deg) * vertexSizeFactor + vertexSizeFactor - V(g)$frame.color <- "white" - V(g)$color <- "orange" - E(g)$color <- "gray65" - E(g)$width <- 0.5 - tl <- TrophInd(get.adjacency(g, sparse = F)) - if (!vertexLabel) - V(g)$label <- NA - if (inherits(g, "mgraph") && ("Trophic" %in% unique(unlist(edge.attributes(g))))) { - tt <- subgraph.edges(g, E(g)[E(g)$type == "Trophic"]) - tl <- TrophInd(get.adjacency(tt, sparse = F)) - } - else { - tl <- TrophInd(get.adjacency(g, sparse = F)) - } - if (is.null(lMat)) { - lMat <- matrix(nrow = vcount(g), ncol = 2) - lMat[, 2] <- jitter(tl$TL, 0.1) - if (modules) { - if (count_components(g) > 1) { - if (!is.named(g)) - V(g)$name <- (1:vcount(g)) - dg <- components(g) - V(g)$membership = 0 - for (comp in unique(dg$membership)) { - g1 <- induced_subgraph(g, which(dg$membership == - comp)) - m <- cluster_spinglass(g1, weights = weights) - if (length(m$membership) == 0) - m$membership <- 1 - V(g)[V(g1)$name]$membership <- m$membership + - max(V(g)$membership) - } - m$membership <- V(g)$membership - } - else { - m <- cluster_spinglass(g, weights = weights) - } - df <- data.frame(tl = tl$TL, m = m$membership) - df <- df %>% mutate(m = dense_rank(ave(tl, m, FUN = max))) - lMat[, 1] <- jitter(df$m, 1) - } - else { - lMat[, 1] <- runif(vcount(g)) - } - } - - colnet <- c("#833f8f", "#ccb7d5","#a8d9c3", "#088a4f") - #(network connector -high connectivity between and within modules-, module connector -few links between modules-, module specialist -few links in its module-, module hub -high # links in its module-) - hc <- topoFrame %>% mutate(type = factor(type)) %>% arrange(node) %>% mutate(col=as.numeric(type), TL=tl[,1]) - V(g)$color <- colnet[hc$col] - - plot(g, - edge.arrow.size = 0.4, - vertex.label.color = "black", - edge.curved = 0.2, - layout = lMat, - vertex.label.cex = 1, - vertex.label.family = "Lato", - vertex.label.font = 3) - - maxnew <- max(tl$TL) - minnew <- min(tl$TL) - maxold <- 1 - minold <- -1 - t2 <- function(x) (maxold - minold)/(maxnew - minnew) * - (x - maxnew) + maxold - tlseq <- seq(1, ifelse(is.null(maxTL), maxnew + 1, maxTL), - by = 1) - par(family = "Lato") - axis(side = 2, at = t2(tlseq), labels=tlseq, las=1, col=NA, col.ticks=NULL, cex.axis=1, lwd.ticks=1) - } - -# Plot networks -tiff("2020/Figures/fw.tif", width=12, height=8, units="in", res=300) -par(mfrow=c(1,2), mar=c(0,2,0,0), oma=c(0,1.5,2.3,0.5), family = "Lato") -ptl(p, hub_connp, vertexLabel=FALSE) -ptl(b, hub_connb, vertexLabel=FALSE) - -# Add axis-y legend -mtext("Trophic level", side=2, outer=TRUE, line=0, cex=1.25, font=2) -par(fig=c(0,1,0,1), family="Lato", new=TRUE) - -# Plots titles -plot(0, 0, type="n", bty="n", xaxt="n", yaxt="n") -mtext("Beagle Channel", side=3, outer=TRUE, line=0.5, cex=1.75, font=2, adj=1) -par(fig=c(0,1,0,1), family="Lato", new=TRUE) - -plot(0, 0, type="n", bty="n", xaxt="n", yaxt="n") -mtext("Potter Cove", side=3, outer=TRUE, line=0.5, cex=1.75, font=2, adj=0) -par(fig=c(0,1,0,1), oma=c(0,0,0,0), mar=c(0,0,1,0), new=TRUE) - -# Add legend -plot(0, 0, type="n", bty="n", xaxt="n", yaxt="n") -colnet1 <- c("#833f8f", "#ccb7d5","#a8d9c3", "#088a4f") -legend("top", legend = c("Network connector", "Module connector", "Module specialist", "Module hub"), col=colnet1, pch=19, cex=0.8, xpd=TRUE, inset=c(0,0), title="Topological roles:") - -dev.off() -``` - -```{r} - -#---- Plot fw by TL -svg("2020/Figures/fwp.svg", width=8, height=8) -par(mfrow=c(1,1), mar=c(0,2,0,0), oma=c(0,1.5,2.3,0.5), family = "Lato") -plot_troph_level(p, vertexSizeFactor = 6, maxTL = 4, edge.color="white") -dev.off() - -svg("2020/Figures/fwb.svg", width=8, height=8) -par(mfrow=c(1,1), mar=c(0,2,0,0), oma=c(0,1.5,2.3,0.5), family = "Lato") -plot_troph_level(b, vertexSizeFactor = 6, maxTL = 4, edge.color="white") -dev.off() - -``` +### Food web plot by trophic level and modules ### -```{r} -#---- Plot fw by TL and mod +```{r plotFW, echo=FALSE, message=FALSE} troph.net1 <- TrophInd(get.adjacency(p, sparse=F), Dead=c("Necromass", "Fresh detritus", "Aged detritus")) layout.matrix.1 <- matrix(nrow=length(V(p)), ncol=2) @@ -187,13 +65,13 @@ troph.net2 <- TrophInd(get.adjacency(b, sparse=F), Dead=c("Necromass", "Fresh de layout.matrix.2 <- matrix(nrow=length(V(b)), ncol=2) # Add colors with topological roles to nodes -colnet <- c("#833f8f", "#ccb7d5","#a8d9c3", "#088a4f") +colnet1 <- c("#833f8f", "#ccb7d5","#a8d9c3", "#088a4f") hcp <- hub_connp %>% mutate(type = factor(type)) %>% arrange(node) %>% mutate(col=as.numeric(type), TL=troph.net1[,1]) -V(p)$color <- colnet[hcp$col] +V(p)$color <- colnet1[hcp$col] hcb <- hub_connb %>% mutate(type = factor(type)) %>% arrange(node) %>% mutate(col=as.numeric(type), TL=troph.net2[,1]) -V(b)$color <- colnet[hcb$col] +V(b)$color <- colnet1[hcb$col] # Transform y-axis coordinates maxnewp <- max(hcp$TL) @@ -215,7 +93,7 @@ layout.matrix.1[,1] <- jitter(mod_by_red[[1]]$membership, 1.2) # randomly assign layout.matrix.2[,2] <- jitter(troph.net2$TL, 0.4) layout.matrix.2[,1] <- jitter(mod_by_red[[2]]$membership, 1.4) -svg("2020/Figures/fw_mod_topo2.svg", width=20, height=10) +svg("Results/fw_mod_TL.svg", width=20, height=10) par(mfrow=c(1,2), mar=c(0,0.5,0,0), oma=c(0,1.5,2.3,0.5), family = "Lato") require(prettyGraphs) @@ -245,7 +123,7 @@ axis(side=2, at=t1(1:5), labels=1:5, las=1, col=NA, col.ticks=1) dev.off() -#svg("2020/Figures/fw_legend.svg", width=5, height=5) +#svg("Results/fw_legend.svg", width=5, height=5) #par(mfrow=c(1,1), mar=c(0,2,0,0), oma=c(0,1.5,2.3,0.5), family = "Lato") # Add legend #plot(0, 0, type="n", bty="n", xaxt="n", yaxt="n") @@ -258,10 +136,6 @@ dev.off() ```{r plotTrait, echo=FALSE, message=FALSE, results='asis'} -colnet <- c("#024828","#066e3f","#088a4f","#51b487","#85caab","#a8d9c3", #VERDE +oscuro- - "#ffffff", - "#40004b","#683272","#833f8f","#9970ab","#b79ac4","#ccb7d5") #VIOLETA +oscuro- - #--- Modules vs habitat #POTTER @@ -328,18 +202,18 @@ col2 <- plot_grid(hfg[[3]], hfg[[4]], ncol=1, nrow=2) col3 <- plot_grid(hfg[[5]], hfg[[6]], ncol=1, nrow=2, labels = c("(b)", "(d)"), label_size=15, label_fontfamily="Lato", hjust=0.25, vjust=2) plot_grid(col1, col2, col3, ncol=3, rel_widths=c(1,0.35,1), scale=0.98) -ggsave("2020/Figures/HFG_PCBC.svg", width=13, height=12) -#ggsave("C:/Users/iamia/Google Drive (iaradiamelar@gmail.com)/Escrito/Paper/HFG_PCBC.tiff", width=13, height=12, units="in", dpi=1000) - +ggsave("Results/HFG_PCBC.svg", width=13, height=12) rm(ph,bh,pfg,bfg,hfg,col1,col2,col3) ``` -```{r} +```{r, echo=FALSE, message=FALSE, results='asis'} + # Total spp x traits plots #-- Habitat + #POTTER cpH_t <- cpH %>% group_by(Habitat) %>% summarise(Total=(sum(Freq)/110)*100) ggplot(cpH_t, aes(x=1, y=Total, fill=Habitat)) + @@ -353,9 +227,9 @@ ggplot(cpH_t, aes(x=1, y=Total, fill=Habitat)) + coord_polar(theta="y") + labs(y="", x="") + theme_void() -ggsave("2020/Figures/cpH_t.svg", width=5, height=5) +ggsave("Results/cpH_t.svg", width=5, height=5) -#BEALGE +#BEAGLE cbH_t <- cbH %>% group_by(Habitat) %>% summarise(Total=(sum(Freq)/145)*100) ggplot(cbH_t, aes(x=1, y=Total, fill=Habitat)) + geom_bar(stat="identity", show.legend=FALSE) + @@ -368,9 +242,10 @@ ggplot(cbH_t, aes(x=1, y=Total, fill=Habitat)) + coord_polar(theta="y") + labs(y="", x="") + theme_void() -ggsave("2020/Figures/cbH_t.svg", width=5, height=5) +ggsave("Results/cbH_t.svg", width=5, height=5) #-- Functional group + #POTTER cpFG_t <- cpFG %>% group_by(FG) %>% summarise(Total=(sum(Freq)/110)*100) ggplot(cpFG_t, aes(x=1, y=Total, fill=FG)) + @@ -381,7 +256,7 @@ ggplot(cpFG_t, aes(x=1, y=Total, fill=FG)) + coord_polar(theta="y") + labs(y="", x="") + theme_void() -ggsave("2020/Figures/cpFG_t.svg", width=5, height=5) +ggsave("Results/cpFG_t.svg", width=5, height=5) #BEAGLE cbFG_t <- cbFG %>% group_by(FG) %>% summarise(Total=(sum(Freq)/145)*100) @@ -393,98 +268,28 @@ ggplot(cbFG_t, aes(x=1, y=Total, fill=FG)) + coord_polar(theta="y") + labs(y="", x="") + theme_void() -ggsave("2020/Figures/cbFG_t.svg", width=5, height=5) +ggsave("Results/cbFG_t.svg", width=5, height=5) rm(cpH_t,cbH_t,cpFG_t,cbFG_t) -``` - - -### Plot stability (Q, QSS) metrics ### - -```{r plotStability, echo=FALSE, message=FALSE, results='asis'} - -datp <- ti %>% filter(Network=="Potter") -simp <- tiMIC %>% filter(Network=="Potter") - -datb <- ti %>% filter(Network=="Beagle") -simb <- tiMIC %>% filter(Network=="Beagle") - -# Trophic coherence - -q13 <- quantile(simp$Q, c(0.005,0.995)) -q14 <- quantile(simb$Q,c(0.005,0.995)) - -g7 <- ggplot(tiMIC, aes(Q)) + - geom_histogram(data=tiMIC, aes(fill=Network), bins=50, show.legend=TRUE) + - scale_fill_manual(values=c(colnet[12], colnet[5]), labels=c("Beagle Channel", "Potter Cove")) + - xlab("Trophic coherence") + - ylab("Frecuency") + - geom_segment(data=datp, aes(x=Q, xend=Q, y=45, yend=0), colour=colnet[2], size=1.3, arrow=arrow(length=unit(0.25, "cm"), type="open", angle=30)) + - geom_text(data=datp, aes(x=Q, y=-19, label=round(Q, 2)), size=4.25, family="Lato", fontface="bold", colour=colnet[2], nudge_y=0, nudge_x=0.011) + - geom_segment(data=datp, aes(x=q13[1], xend=q13[1], y=35, yend=0), colour=colnet[2], size=1.25, linetype=1) + - geom_segment(data=datp, aes(x=q13[2], xend=q13[2], y=35, yend=0), colour=colnet[2], size=1.25, linetype=1) + - geom_segment(data=datb, aes(x=Q, xend=Q, y=45, yend=0), colour=colnet[9], size=1.3, arrow=arrow(length=unit(0.25, "cm"), type="open", angle=30)) + - geom_text(data=datb, aes(x=Q, y=-19, label=round(Q, 2)), size=4.25, family="Lato", fontface="bold", colour=colnet[9], nudge_y=0, nudge_x=-0.012) + - geom_segment(data=datb, aes(x=q14[1], xend=q14[1], y=35, yend=0), colour=colnet[9], size=1.25, linetype=1) + - geom_segment(data=datb, aes(x=q14[2], xend=q14[2], y=35, yend=0), colour=colnet[9], size=1.25, linetype=1) + - theme_new + - coord_cartesian(ylim=c(-8, 580)) + - guides(fill=guide_legend(reverse=TRUE)) + - theme(legend.position="top") - -# Quasi-sign stabilty - -require(binom) -df <- ti %>% dplyr::select(Network, QSS) %>% group_by(Network) %>% do(binom.confint(.$QSS*10000, 10000, methods="wilson")) - -df$Network <- factor(df$Network, levels=c("Potter", "Beagle")) -levels(df$Network) <- c("Potter Cove", "Beagle Channel") - -gqss <- ggplot(df, aes(Network, mean, color=Network)) + - geom_point() + - geom_errorbar(aes(ymin=lower, ymax=upper), width=0.15) + - xlab("") + - ylab("Quasi-sign stability") + - scale_colour_manual(values=c(colnet[3], colnet[10])) + - theme_new + - theme(legend.position="none", - axis.text.x=element_text(size=16, face="plain", family="Lato", margin=margin(t=8, r=0, b=0, l=0)), - axis.title.y=element_text(size=18, face="bold", family="Lato", margin=margin(t=8, r=0, b=0, l=0))) + - coord_cartesian(ylim=c(-0.00055, 0.039)) - -gqss <- gqss + coord_flip() + theme(axis.text.y=element_text(size=16, angle=90, hjust=0.5), - axis.text.x=element_text(size=10)) - -# Add all plots into a single plot - -plot_grid(g7, gqss, - nrow=1, ncol=2, - labels=c("(a)","(b)"), label_size=15, label_fontfamily="Lato", hjust=0, vjust=5.1, - scale=0.98, - align=c("hv", "hv"), - axis=c("tb")) - -ggsave("C:/Users/iamia/Google Drive (iaradiamelar@gmail.com)/Escrito/Paper/Q_QSS.tiff", width=11, height=5.5, units="in", dpi=1000) - - -#rm(datp,datb,simp,simb,q13,q14,g7,df,gqss) ``` -### Plot topology metrics ### + +### Plot structure and stability metrics ### ```{r plotTopology, echo=FALSE, message=FALSE, results='asis'} -datp <- ti %>% filter(Network=="Potter") -simp <- tiMIC %>% filter(Network=="Potter") +datp <- ti %>% filter(Network=="Potter") #empiric metrics for Potter +simp <- tiMIC %>% filter(Network=="Potter") #curveball randomizations metrics for Potter + +datb <- ti %>% filter(Network=="Beagle") #empiric metrics for Beagle +simb <- tiMIC %>% filter(Network=="Beagle") #curveball randomizations metrics for Beagle -datb <- ti %>% filter(Network=="Beagle") -simb <- tiMIC %>% filter(Network=="Beagle") # Mean trophic level -q1 <- quantile(simp$TLmean, c(0.005,0.995)) -q2 <- quantile(simb$TLmean, c(0.005,0.995)) +q1 <- quantile(simp$TLmean, c(0.005,0.995)) #95% confidence interval for Potter mean TL +q2 <- quantile(simb$TLmean, c(0.005,0.995)) #95% confidence interval for Beagle mean TL #legend1 <- get_legend(g1) g1 <- ggplot(tiMIC, aes(TLmean)) + @@ -578,193 +383,10 @@ row3 <- plot_grid(NULL, ggg[[5]], NULL, ncol=3, rel_widths=c(0.25,0.5,0.25)) plot_grid(row3, row1, row2, ncol=1, rel_heights=c(0.15,1,1)) -ggsave("C:/Users/Iara Diamela/Downloads/curveball.tiff", width=11, height=12, units="in", dpi=300) +ggsave("Results/curveball.svg", width=11, height=12, units="in", dpi=300) #rm(datp,datb,simp,simb) #rm(q1,q2,q3,q4,q5,q6,q7,q8,q9,q10) #rm(g1,g2,g3,g4,g5,ggg,row1,row2,row3,row4) ``` - -### Plot smallworld ### - -```{r plotSmallworld, echo=FALSE, message=FALSE, results='asis'} - -#ti$Network <- factor(ti$Network, levels=c("Potter", "Beagle")) -#levels(ti$Network) <- c("Potter Cove", "Beagle Channel") -#smallWorldness$Network <- factor(smallWorldness$Network, levels=c("Potter", "Beagle")) -#levels(smallWorldness$Network) <- c("Potter Cove", "Beagle Channel") - -# Clustering coefficient - -gsmw_cc <- ggplot(ti, aes(Clustering, x=Network, color=Network)) + - geom_point(aes(size=2)) + - geom_line(data=smallWorldness, aes(Network, clus.coef), size=1.5) + - scale_colour_manual(values=c(colnet[3], colnet[10])) + - xlab("") + - ylab("Clustering coefficient") + - theme_new + - theme(legend.position="none", - axis.text.x=element_text(size=16, face="plain", family="Lato", margin=margin(t=8, r=0, b=0, l=0)), - axis.title.y=element_text(size=18, face="bold", family="Lato", margin=margin(t=8, r=0, b=0, l=0))) - -gsmw_cc <- gsmw_cc + coord_flip() + theme(axis.text.y=element_text(size=16, angle=90, hjust=0.5), - axis.text.x=element_text(size=10)) - -# Characteristic path length - -gsmw_cpl <- ggplot(ti, aes(PathLength, x=Network, color=Network)) + - geom_point(aes(size=2)) + - geom_line(data=smallWorldness, aes(Network, cha.path), size=1.5) + - scale_colour_manual(values=c(colnet [3], colnet[10])) + - xlab("") + - ylab("Characteristic path length") + - theme_new + - theme(legend.position="none", - axis.text.x=element_text(size=16, face="plain", family="Lato", margin=margin(t=8, r=0, b=0, l=0)), - axis.title.y=element_text(size=18, face="bold", family="Lato", margin=margin(t=8, r=0, b=0, l=0))) - - -gsmw_cpl <- gsmw_cpl + coord_flip() + theme(axis.text.y=element_blank(), - axis.text.x=element_text(size=10)) - -# Add all plots into a single plot - -plot_grid(gsmw_cc, gsmw_cpl, - nrow=1, ncol=2, - labels=c("(a)","(b)"), label_size=15, label_fontfamily="Lato", hjust=-0.7, vjust=2, - scale=0.98, - align=c("hv", "hv"), - axis=c("tb")) - -ggsave("C:/Users/iamia/Google Drive (iaradiamelar@gmail.com)/Escrito/Paper/smallworld.tiff", width=11, height=5.5, units="in", dpi=1000) - -``` - -```{r} - -dgp <- data.frame(degree(p)) %>% mutate(Name="Potter") -colnames(dgp) <- c("Degree", "Network") -dgp.histogram <- as.data.frame(table(dgp)) -dgp.histogram[,1] <- as.numeric(dgp.histogram[,1]) - -dgb <- data.frame(degree(b)) %>% mutate(Name="Beagle") -colnames(dgb) <- c("Degree", "Network") -dgb.histogram <- as.data.frame(table(dgb)) -dgb.histogram[,1] <- as.numeric(dgb.histogram[,1]) - -dg <- bind_rows(dgp.histogram, dgb.histogram) - - -ggplot(dg, aes(x=Degree, y=Freq, color=Network)) + geom_point() + theme_new + - scale_x_continuous("Degree\n(nodes with this amount of connections)", - breaks = c(1, 3, 10, 30, 100, 300), - trans = "log10") + - scale_y_continuous("Frequency\n(how many of them)", - breaks = c(1, 3, 10, 30, 100, 300, 1000), - trans = "log10") - -rm(dgp,dgb.histogram,dgb.histogram,dg) - -``` - - -### Plot degree distribution### -```{r} -require(poweRlaw) - -#---POTTER -p1 <- degree(p) - -# Power law -m1 <- displ$new(p1) -est <- estimate_xmin(m1) -m1$setXmin(est) -m1$setXmin(1) -alf <- estimate_pars(m1) -m1$setPars(alf) - -# Log normal -m2 <- dislnorm$new(p1) -est2 <- estimate_xmin(m2) -m2$setXmin(est2) -m2$setXmin(1) -alf2 <- estimate_pars(m2) -m2$setPars(alf2) - -# Poisson -m3 <- dispois$new(p1) -est3 <- estimate_xmin(m3) -m3$setXmin(est3) -m3$setXmin(1) -alf3 <- estimate_pars(m3) -m3$setPars(alf3) - -# Exponential -m4 <- disexp$new(p1) -est4 <- estimate_xmin(m4) -m4$setXmin(est4) -m4$setXmin(1) -alf4 <- estimate_pars(m4) -m4$setPars(alf4) - - -#---BEAGLE -b1 <- degree(b) - -# Power law -m5 <- displ$new(b1) -est <- estimate_xmin(m5) -m5$setXmin(est) -m5$setXmin(1) -alf5 <- estimate_pars(m5) -m5$setPars(alf5) - -# Log normal -m6 <- dislnorm$new(b1) -est6 <- estimate_xmin(m6) -m6$setXmin(est6) -m6$setXmin(1) -alf6 <- estimate_pars(m6) -m6$setPars(alf6) - -# Poisson -m7 <- dispois$new(b1) -est7 <- estimate_xmin(m7) -m7$setXmin(est7) -m7$setXmin(1) -alf7 <- estimate_pars(m7) -m7$setPars(alf7) - -# Exponential -m8 <- disexp$new(b1) -est8 <- estimate_xmin(m8) -m8$setXmin(est8) -m8$setXmin(1) -alf8 <- estimate_pars(m8) -m8$setPars(alf8) - - -# Plots -#tiff("C:/Users/Iara Diamela/Downloads/degree.tif", width=18, height=10, units="in", res=300) -svg("2020/Figures/degree.svg", width=18, height=10) -par(mfrow=c(1,2), mar=c(5,5,3,2), oma=c(1,1,1,1), family = "Lato", cex.axis=1.2, cex.lab=1.8) - -plot(m1, xlim=c(1,60), ylab="Cumulative distribution", xlab="Degree", main="Potter Cove", cex.main=2.2, pch=19, col=colnet[4], cex=1.4, ylim=c(0.01,1)) -lines(m1, lty=1) #power -lines(m2, lty=2) #lognorm -lines(m3, lty=3) #pois -lines(m4, lty=4, lwd=2.5) #exp -legend(c(0.02,0.0235), c("Power-Law", "Log Normal", "Poisson", "Exponential"), lty= c(1,2,3,4), box.lty=0, cex=1.5) - -plot(m5, xlim=c(1,60), ylab="", xlab="Degree", main="Beagle Channel", cex.main=2.2, pch=19, col=colnet[11], cex=1.4, ylim=c(0.01,1)) -lines(m5, lty=1) #power -lines(m6, lty=2) #lognorm -lines(m7, lty=3) #pois -lines(m8, lty=4) #exp - -dev.off() - -#rm(b1,p1,m1,m2,m3,m4,m5,m6,m7,m8,alf,afl2,alf3,alf4,alf5,alf6,alf7,alf8,est,est2,est3,est4,est5,est6,est7,est8) -``` -