0

I have the following plot:

enter image description here

Generated with

all$lvl <- factor(all$Criteria, levels=c("A", "B", "C", "D"))
ggplot(all, aes(x=Date, y=Users, color=Answer, group=Answer)) + 
geom_point(size=1.5) + geom_line(size=1.5) +
theme_hc() + theme(axis.text.x=element_blank(), axis.ticks.x=element_blank()) + facet_grid(.~lvl) +
scale_y_continuous(labels=percent) 

The line connects the values from my dataframe with discrete values for both x and y. How do I fill the area below the lines? With geom_area I get weird results:

enter image description here

geom_area(linetype=1, size=0.2, color="black", aes(fill=Answer))

I suppose this is because geom_area is for continuous values. Is there a way to do this for a discrete data set? Superimposing the line makes the weirdness more obvious:

enter image description here

I tried other values for stat other than the identity default, without success. As I understand it, identity shouldn't change the data...

Alex
  • 1,416
  • 4
  • 16
  • 42
  • You should include sample data to make your problem [reproducible](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). What precisely is "weird" about the results? What exactly do you expect the plot to look like for your data? – MrFlick Mar 11 '16 at 05:44

1 Answers1

2

geom_area defaults to position = "stack", which is why the two colour regions are stacked instead of overlapping. Try position = "identity".

baptiste
  • 75,767
  • 19
  • 198
  • 294