I have a data set that's structured as follows:
year color toyota honda ford
2011 blue 66 75 13
2011 red 75 91 62
2011 green 65 26 57
2012 blue 64 23 10
2012 red 84 8 62
2012 green 67 21 62
2013 blue 31 74 49
2013 red 48 43 35
2013 green 57 62 74
2014 blue 59 100 32
2014 red 72 47 67
2014 green 97 24 70
2015 blue 31 0 79
2015 red 60 35 74
2015 green 51 2 28
(My actual data, presented in the chart images below, is much larger and has 100s of "colors" but I'm simplifying here so you can merely understand the structure.)
I am trying to make a stacked area line chart that shows how many cars of each color are produced over time for a specific company. (i.e. each company has its own chart in which x axis = years, y axis = cars produced).
I run this code:
qplot(year, toyota, data = dataName, fill = color, group = color, geom= "area", position = "stack")
+ geom_area() + theme(legend.position = "none")
However, every company's chart has issues. There are seemingly random cut-out holes as well as lines that cut across the top of the layers.
I'm confused why this is happening or even possible (especially the holes... won't the data stack down?) Would it help if I made the companies long rather than wide in the data structure?