Stacked bar chart with continuous Y variables



*Updated with an example
I am trying to make a stacked bar chart where the x-axis is categorical, by the y-axis is continuous. As it is, my code produces a bar chart where instead of a stacked chart, the bars are colored to designate the value for the second y-value. I want to produce a typical stacked chart where the color changes where the first y-variable ends. Here is my current code:

Bar <- ggplot(iris,aes(Species,Sepal.Width,fill=Sepal.Length))+

Created on 2019-02-05 by the reprex package (v0.2.1)


We don't really have enough info to help you out. Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.


I think I accomplished that. Thanks!


A stacked bar chart is intended usually with color variables that are factor variables rather than continuous. Your code is mapping the fill aesthetic to a continuous variable, Sepal.Length, which is why ggplot2 is using colors in this way. If you want a continuous y-axis and want a stacked bar chart, the variable you map onto the fill aesthetic needs to be a factor variable. You can see some example plots/code here:


You were very close on your reprex, the idea was to use a small sample of your own data, but if you want to use the iris data set, there is no need for the df_paste() call, since iris comes with R by default.


I don't understand what you're going for. Could you share a drawing of your goal?


Nice, art by accident!


How do you expect this to work? I honestly don't even know what it means to "stack a continuous variable"