0

I am trying to do a stacked area plot in order to compare outcomes under three scenarios.

ggplot(FIREP_All,aes(x = Time, y = Houses, fill=Risk_Class, group=  Risk_Class))+ geom_line(aes(ymax=Houses), position="stack", colour='darkgrey')+ geom_area(alpha=.75) +
  scale_fill_brewer(type="seq", palette=18,name = "Fire Risk Class")+facet_grid(~Scenario)  

enter image description here

Although I know that stacked area plots are cumulative, I want to set a ylim, so that it is easier to see difference between the scenarios. Preferably ylim(1e7,2.5e7). The problem is that it interferes with the calculations.

    ggplot(FIREP_All,aes(x = Time, y = Houses, fill=Risk_Class, group=  Risk_Class))+ geom_line(aes(ymax=Houses), position="stack", colour='darkgrey')+ geom_area(alpha=.75) + scale_fill_brewer(type="seq", palette=18,name = "Fire Risk Class")+facet_grid(~Scenario)  

+ylim(1e7,2.5e7)

enter image description here

Any thoughts on a work around?

mmann1123
  • 5,031
  • 7
  • 41
  • 49

1 Answers1

2

To zoom the plot you should use coord_cartesian() with ylim= as argument.

 + coord_cartesian(ylim=c(1e7,2.5e7))
Didzis Elferts
  • 95,661
  • 14
  • 264
  • 201