How to remove space between axis & area-plot in ggplot2?

前端 未结 3 1477
醉话见心
醉话见心 2020-11-22 06:49

I have the following dataframe:

uniq <- structure(list(year = c(1986L, 1987L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L,         


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 07:23

    Another option producing identical results, is using coord_cartesian instead of continuous position scales (x & y):

    ggplot(data = uniq) +  
      geom_area(aes(x = year, y = uniq.p, fill = uniq.loc), stat = "identity", position = "stack") +  
      coord_cartesian(xlim = c(1986,2014), ylim = c(0,101))+
      theme_bw() + theme(panel.grid=element_blank(), panel.border=element_blank())
    

提交回复
热议问题