`[![library library(ggplot2)
library(lubridate)
library(gridExtra)
library(ggpubr)
library(Cairo)
library(cairoDevice)
#data.frame do grafico 1
dados <- read.table(text =
"Mes local1 captura1 local2 captura2 eixo
Out 36 0.02 17 0 0
Nov 36 0.02 17 0 0
Dez 36 10 17 10 10
Jan 36 10 17 10 0
", header = T)
head(dados)
levels(dados$Mes)
dados$Mes = factor(dados$Mes, levels=c("Out", "Nov", "Dez", "Jan"))
g_point1 <- ggplot(subset(dados, Mes %in% c("Out", "Nov")), aes(Mes)) +
geom_line(aes(y = captura1, color = "ADULTO"), size=1,linetype=1, group = 1)+
geom_line(aes(y = captura2, color = "LARVA"), size=1,linetype=3, group = 2)+
geom_point(aes(y = captura1), color="red", size=4, group = 1, shape=18) +
geom_point(aes(y = captura2), color="black", size=2, group = 2)+
scale_x_discrete(limits = levels(dados$Mes)) +
scale_y_continuous(breaks = c(0:5), limits = c(0,5))+
theme_grey()+
labs(x = "Período", y = "", title = "Evolução de larvas e adultos", subtitle = "Zona 36") +
scale_color_manual(name= "", values=c("red", "black"),
guide = guide_legend(override.aes=aes(fill=group))) +
theme(legend.position=c("right"),
plot.subtitle = element_text(size = 12, face = "bold"),
axis.text.x=element_text(face = "bold", color = "black", size = 10),
axis.text.y=element_text(face = "bold", color = "black",size = 13),
panel.background = element_rect ( fill = NA ) ,
panel.grid.major = element_line ( color = "gray89" ) ,
panel.ontop = F,
axis.line = element_line(colour = "black", size = 1))
#data.frame do grafico 2
dados <- read.table(text =
"Mes local1 captura1 local2 captura2 eixo
11.10 19 0 19 46 0
Out 19 5 19 23 0
04.11 19 8 19 18 0
Nov 19 18 19 5 0
Dez 19 10 19 10 10
Jan 19 10 19 10 0
", header = T)
head(dados)
levels(dados$Mes)
dados$Mes = factor(dados$Mes, levels=c("11.10","Out", "04.11","Nov", "Dez", "Jan"))
g_point2 <- ggplot(subset(dados, Mes %in% c("11.10","Out","04.11","Nov")), aes(Mes)) +
geom_line(aes(y = captura1, color = "ADULTO"), size=1,linetype=1, group = 1)+
geom_line(aes(y = captura2, color = "LARVA"), size=1,linetype=3, group = 2)+
geom_point(aes(y = captura1), color="red", size=4, group = 1, shape=18) +
geom_point(aes(y = captura2), color="black", size=2, group = 2)+
scale_x_discrete(limits = levels(dados$Mes))+
scale_y_continuous()+
theme_grey()+
labs(x = "Período", y = "", title = "Evolução de larvas e adultos", subtitle = "Zona 19") +
scale_color_manual(name= "", values=c("red", "black"),
guide = guide_legend(override.aes=aes(fill=group)))+
theme(legend.position=c("right"),
plot.subtitle = element_text(size = 12, face = "bold"),
axis.text.x=element_text(face = "bold", color = "black", size = 10),
axis.text.y=element_text(face = "bold", color = "black",size = 13),
panel.background = element_rect ( fill = NA ) ,
panel.grid.major = element_line ( color = "gray89" ) ,
panel.ontop = F,
axis.line = element_line(colour = "black", size = 1))
ggarrange(g_point1 + labs(x = "Período"), g_point2 + labs(x = "Período"),
ncol = 2, align = "v",
common.legend = T, legend = "right")`
`[![library(ggplot2)
library(lubridate)
library(gridExtra)
library(ggpubr)
library(Cairo)
library(cairoDevice)
#data.frame do grafico 1
dados <- read.table(text =
"Mes local1 captura1 local2 captura2 eixo
Out 36 0.02 17 0 0
Nov 36 0.02 17 0 0
Dez 36 10 17 10 10
Jan 36 10 17 10 0
", header = T)
head(dados)
levels(dados$Mes)
dados$Mes = factor(dados$Mes, levels=c("Out", "Nov", "Dez", "Jan"))
g_point1 <- ggplot(subset(dados, Mes %in% c("Out", "Nov")), aes(Mes)) +
geom_line(aes(y = captura1, color = "ADULTO"), size=1,linetype=1, group = 1)+
geom_line(aes(y = captura2, color = "LARVA"), size=1,linetype=3, group = 2)+
geom_point(aes(y = captura1), color="red", size=4, group = 1, shape=18) +
geom_point(aes(y = captura2), color="black", size=2, group = 2)+
scale_x_discrete(limits = levels(dados$Mes)) +
scale_y_continuous(breaks = c(0:5), limits = c(0,5))+
theme_grey()+
labs(x = "Período", y = "", title = "Evolução de larvas e adultos", subtitle = "Zona 36") +
scale_color_manual(name= "", values=c("red", "black"),
guide = guide_legend(override.aes=aes(fill=group))) +
theme(legend.position=c("right"),
plot.subtitle = element_text(size = 12, face = "bold"),
axis.text.x=element_text(face = "bold", color = "black", size = 10),
axis.text.y=element_text(face = "bold", color = "black",size = 13),
panel.background = element_rect ( fill = NA ) ,
panel.grid.major = element_line ( color = "gray89" ) ,
panel.ontop = F,
axis.line = element_line(colour = "black", size = 1))
#data.frame do grafico 2
dados <- read.table(text =
"Mes local1 captura1 local2 captura2 eixo
11.10 19 0 19 46 0
Out 19 5 19 23 0
04.11 19 8 19 18 0
Nov 19 18 19 5 0
Dez 19 10 19 10 10
Jan 19 10 19 10 0
", header = T)
head(dados)
levels(dados$Mes)
dados$Mes = factor(dados$Mes, levels=c("11.10","Out", "04.11","Nov", "Dez", "Jan"))
g_point2 <- ggplot(subset(dados, Mes %in% c("11.10","Out","04.11","Nov")), aes(Mes)) +
geom_line(aes(y = captura1, color = "ADULTO"), size=1,linetype=1, group = 1)+
geom_line(aes(y = captura2, color = "LARVA"), size=1,linetype=3, group = 2)+
geom_point(aes(y = captura1), color="red", size=4, group = 1, shape=18) +
geom_point(aes(y = captura2), color="black", size=2, group = 2)+
scale_x_discrete(limits = levels(dados$Mes))+
scale_y_continuous()+
theme_grey()+
labs(x = "Período", y = "", title = "Evolução de larvas e adultos", subtitle = "Zona 19") +
scale_color_manual(name= "", values=c("red", "black"),
guide = guide_legend(override.aes=aes(fill=group)))+
theme(legend.position=c("right"),
plot.subtitle = element_text(size = 12, face = "bold"),
axis.text.x=element_text(face = "bold", color = "black", size = 10),
axis.text.y=element_text(face = "bold", color = "black",size = 13),
panel.background = element_rect ( fill = NA ) ,
panel.grid.major = element_line ( color = "gray89" ) ,
panel.ontop = F,
axis.line = element_line(colour = "black", size = 1))
ggarrange(g_point1 + labs(x = "Período"), g_point2 + labs(x = "Período"),
ncol = 2, align = "v",
common.legend = T, legend = "right")`
library(ggplot2)
library(lubridate)
library(gridExtra)
library(ggpubr)
library(Cairo)
library(cairoDevice)
#data.frame do grafico 1
dados <- read.table(text =
"Mes local1 captura1 local2 captura2 eixo
Out 36 0.02 17 0 0
Nov 36 0.02 17 0 0
Dez 36 10 17 10 10
Jan 36 10 17 10 0
", header = T)
head(dados)
levels(dados$Mes)
dados$Mes = factor(dados$Mes, levels=c("Out", "Nov", "Dez", "Jan"))
g_point1 <- ggplot(subset(dados, Mes %in% c("Out", "Nov")), aes(Mes)) +
geom_line(aes(y = captura1, color = "ADULTO"), size=1,linetype=1, group = 1)+
geom_line(aes(y = captura2, color = "LARVA"), size=1,linetype=3, group = 2)+
geom_point(aes(y = captura1), color="red", size=4, group = 1, shape=18) +
geom_point(aes(y = captura2), color="black", size=2, group = 2)+
scale_x_discrete(limits = levels(dados$Mes)) +
scale_y_continuous(breaks = c(0:5), limits = c(0,5))+
theme_grey()+
labs(x = "Período", y = "", title = "Evolução de larvas e adultos", subtitle = "Zona 36") +
scale_color_manual(name= "", values=c("red", "black"),
guide = guide_legend(override.aes=aes(fill=group))) +
theme(legend.position=c("right"),
plot.subtitle = element_text(size = 12, face = "bold"),
axis.text.x=element_text(face = "bold", color = "black", size = 10),
axis.text.y=element_text(face = "bold", color = "black",size = 13),
panel.background = element_rect ( fill = NA ) ,
panel.grid.major = element_line ( color = "gray89" ) ,
panel.ontop = F,
axis.line = element_line(colour = "black", size = 1))
#data.frame do grafico 2
dados <- read.table(text =
"Mes local1 captura1 local2 captura2 eixo
11.10 19 0 19 46 0
Out 19 5 19 23 0
04.11 19 8 19 18 0
Nov 19 18 19 5 0
Dez 19 10 19 10 10
Jan 19 10 19 10 0
", header = T)
head(dados)
levels(dados$Mes)
dados$Mes = factor(dados$Mes, levels=c("11.10","Out", "04.11","Nov", "Dez", "Jan"))
g_point2 <- ggplot(subset(dados, Mes %in% c("11.10","Out","04.11","Nov")), aes(Mes)) +
geom_line(aes(y = captura1, color = "ADULTO"), size=1,linetype=1, group = 1)+
geom_line(aes(y = captura2, color = "LARVA"), size=1,linetype=3, group = 2)+
geom_point(aes(y = captura1), color="red", size=4, group = 1, shape=18) +
geom_point(aes(y = captura2), color="black", size=2, group = 2)+
scale_x_discrete(limits = levels(dados$Mes))+
scale_y_continuous()+
theme_grey()+
labs(x = "Período", y = "", title = "Evolução de larvas e adultos", subtitle = "Zona 19") +
scale_color_manual(name= "", values=c("red", "black"),
guide = guide_legend(override.aes=aes(fill=group)))+
theme(legend.position=c("right"),
plot.subtitle = element_text(size = 12, face = "bold"),
axis.text.x=element_text(face = "bold", color = "black", size = 10),
axis.text.y=element_text(face = "bold", color = "black",size = 13),
panel.background = element_rect ( fill = NA ) ,
panel.grid.major = element_line ( color = "gray89" ) ,
panel.ontop = F,
axis.line = element_line(colour = "black", size = 1))
ggarrange(g_point1 + labs(x = "Período"), g_point2 + labs(x = "Período"),
ncol = 2, align = "v",
common.legend = T, legend = "right")
Como alterar o estilo da legenda no ggplot?
Como alterar o estilo da legenda do gráfico abaixo para que apareça o tipo da linha + o simbolo correspondente ?
Segue abaixo o comando utilizado.
`[![library(ggplot2)
library(lubridate)
library(gridExtra)
library(ggpubr)
library(Cairo)
library(cairoDevice)
#data.frame do grafico 1
dados <- read.table(text =
"Mes local1 captura1 local2 captura2 eixo
Out 36 0.02 17 0 0
Nov 36 0.02 17 0 0
Dez 36 10 17 10 10
Jan 36 10 17 10 0
", header = T)
head(dados)
levels(dados$Mes)
dados$Mes = factor(dados$Mes, levels=c("Out", "Nov", "Dez", "Jan"))
g_point1 <- ggplot(subset(dados, Mes %in% c("Out", "Nov")), aes(Mes)) +
geom_line(aes(y = captura1, color = "ADULTO"), size=1,linetype=1, group = 1)+
geom_line(aes(y = captura2, color = "LARVA"), size=1,linetype=3, group = 2)+
geom_point(aes(y = captura1), color="red", size=4, group = 1, shape=18) +
geom_point(aes(y = captura2), color="black", size=2, group = 2)+
scale_x_discrete(limits = levels(dados$Mes)) +
scale_y_continuous(breaks = c(0:5), limits = c(0,5))+
theme_grey()+
labs(x = "Período", y = "", title = "Evolução de larvas e adultos", subtitle = "Zona 36") +
scale_color_manual(name= "", values=c("red", "black"),
guide = guide_legend(override.aes=aes(fill=group))) +
theme(legend.position=c("right"),
plot.subtitle = element_text(size = 12, face = "bold"),
axis.text.x=element_text(face = "bold", color = "black", size = 10),
axis.text.y=element_text(face = "bold", color = "black",size = 13),
panel.background = element_rect ( fill = NA ) ,
panel.grid.major = element_line ( color = "gray89" ) ,
panel.ontop = F,
axis.line = element_line(colour = "black", size = 1))
#data.frame do grafico 2
dados <- read.table(text =
"Mes local1 captura1 local2 captura2 eixo
11.10 19 0 19 46 0
Out 19 5 19 23 0
04.11 19 8 19 18 0
Nov 19 18 19 5 0
Dez 19 10 19 10 10
Jan 19 10 19 10 0
", header = T)
head(dados)
levels(dados$Mes)
dados$Mes = factor(dados$Mes, levels=c("11.10","Out", "04.11","Nov", "Dez", "Jan"))
g_point2 <- ggplot(subset(dados, Mes %in% c("11.10","Out","04.11","Nov")), aes(Mes)) +
geom_line(aes(y = captura1, color = "ADULTO"), size=1,linetype=1, group = 1)+
geom_line(aes(y = captura2, color = "LARVA"), size=1,linetype=3, group = 2)+
geom_point(aes(y = captura1), color="red", size=4, group = 1, shape=18) +
geom_point(aes(y = captura2), color="black", size=2, group = 2)+
scale_x_discrete(limits = levels(dados$Mes))+
scale_y_continuous()+
theme_grey()+
labs(x = "Período", y = "", title = "Evolução de larvas e adultos", subtitle = "Zona 19") +
scale_color_manual(name= "", values=c("red", "black"),
guide = guide_legend(override.aes=aes(fill=group)))+
theme(legend.position=c("right"),
plot.subtitle = element_text(size = 12, face = "bold"),
axis.text.x=element_text(face = "bold", color = "black", size = 10),
axis.text.y=element_text(face = "bold", color = "black",size = 13),
panel.background = element_rect ( fill = NA ) ,
panel.grid.major = element_line ( color = "gray89" ) ,
panel.ontop = F,
axis.line = element_line(colour = "black", size = 1))
ggarrange(g_point1 + labs(x = "Período"), g_point2 + labs(x = "Período"),
ncol = 2, align = "v",
common.legend = T, legend = "right")`
lang-r