1

I created 25 plots using the ggplots2 library and I'm especially interested in the Geom_Area function. However, I would like to create square plots, with wider x-axis instead of those small rectangle plots stacked next to each other. I used this function to create my 25 variable plots using this code:

fevd_res = fevd(A, Sigma, 20)


p = ggplot(data=fevd_res, aes(x=h, y=value, fill=j)) +
  geom_area(position = "fill") +
  facet_wrap(k ~ .) +
  scale_x_continuous(
    expand=c(0,0)
  ) +
  scale_fill_discrete(
    name = "Shock"
  ) +
  labs(
    y = "Variance contribution",
    x = "Forecast horizon"
  ) +
  theme_bw()

Create proportional geom_area plot directly in ggplot2

This problem looks similiar to mine, so I tried adding: position = "fill". This did not work as you see by the output below. Hope someone can help, would mean a lot to me!

enter image description here

Manfretto
  • 83
  • 5
  • 4
    it only looks like this because your legend is taking up too much space. Try adding `+ theme(legend.position = "none")` to your plot and you will see what I mean. – Allan Cameron Jul 03 '20 at 12:48

0 Answers0