0
I would like to leave plotted in the graph below only the values referring to the months of JAN and FEV of the x-axis.
The idea is to keep every month of the X-axis evident in the graph and over time go feeding the variables with future values.
I was unsuccessful in the polls.
Follows the command used and a model illustrating how to plot wish.
dados <- read.table(text =
"Mes local1 captura1 local2 captura2
Jan 15 0 17 -0.002
Fev 15 0 17 -0.02
Mar 15 1500 17 85
Abr 15 500 17 78
Mai 15 1490 17 80
Jun 15 1500 17 87
Jul 15 1600 17 82
Ago 15 1750 17 64
Set 15 1800 17 86
Out 15 1450 17 73
Nov 15 1600 17 61
Dez 15 1400 17 92
", header = T)
head(dados)
levels(dados$Mes)
dados$Mes = factor(dados$Mes, levels=c("Jan", "Fev", "Mar", "Abr", "Mai", "Jun",
"Jul", "Ago", "Set", "Out", "Nov", "Dez"))
ggplot(dados, aes(x = Mes)) +
geom_line(aes(y = captura1, color="15"), size=1, group = 1, linetype=1) +
geom_line(aes(y = captura2*14, color="17"), size=1, group = 2, linetype=4) +
geom_point(aes(y = captura1), color="purple", size=4, group = 1, shape=18) +
geom_point(aes(y = captura2*14), color="red", size=4, group = 2) +
scale_y_continuous(sec.axis = sec_axis(~./14, name = "Total de capturas 2")) +
labs(y = "Total de capturas 1", x = "Tempo (meses)") +
scale_color_manual(name="LOCAL", values=c("#35978f", "#003c30"),
guide = guide_legend(override.aes=aes(fill=group))) +
theme(legend.position=c(.8, 0.3))