4
I want to plot the columns analise1
, analise2
, analise3
in a single chart of lines but with different scales, because the width of the column analise1
is much larger than the other two columns. On the x axis would be the years that are in the column Período
, I did not put in date format because the last data in this column is for several years. This visualization would allow to see the behavior of the three analyses over time.
I thought about using ggplot and facet_wrap, but I stumbled upon the following difficulty: how to define the interval in y, since the limits would be the lowest and highest value of each column? I would need to insert a column in df
for each of the graphs and play random values within the amplitude range of each column?
My data:
> dput(df)
structure(list(Período = c("1990", "1991", "1992", "1993", "1994",
"1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002",
"2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010",
"2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018",
"2019", "30anos"), analise1 = c(-17.4, 0.6, -2.3, -14.3, 1.8,
-22.1, -28, 1.4, -26.1, -18.6, -20.4, -35.1, -25.8, -26.8, -17.1,
-32.4, -17.5, -13.4, -32.7, -18.2, -22.6, -23.4, -43.5, -17.1,
-35.2, -22.5, -15.8, -25.5, -19.6, -36.4, -20.9), analise2 = c(0.08,
0.05, 0.03, 0.14, 0.26, 0.09, 0.11, 0.22, 0.16, -0.05, 0.17,
0.13, 0, 0.16, 0.09, 0.16, 0.1, 0.28, 0.17, 0.05, 0.22, 0.21,
0.19, 0.18, 0.16, 0.22, 0.28, 0.18, 0.29, 0.08, 0.15), analise3 = c(0.33,
0.36, 0.35, 0.44, 0.61, 0.34, 0.36, 0.5, 0.42, 0.29, 0.44, 0.39,
0.32, 0.42, 0.4, 0.42, 0.38, 0.54, 0.44, 0.38, 0.47, 0.48, 0.48,
0.44, 0.42, 0.49, 0.53, 0.44, 0.55, 0.34, 0.42)), row.names = c(NA,
-31L), class = "data.frame")
Marcus Nunes thank you so much! As always, fantastic your guidance and didactic. I have a question in the code you made: is possible with the
facet_wrap
put each graph "on top of each other" instead of "next to each other"?– Bruna
Put the option
ncol = 1
within thefacet_wrap
– Carlos Eduardo Lagosta
Could you tell me how to increase facet sizes (parse1, parse2, parse3) and caption? I was able to change only the sizes and styles of the titles and scales.
– Bruna