*Updated with an example
Hello,
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:
library(ggplot2)
Bar <- ggplot(iris,aes(Species,Sepal.Width,fill=Sepal.Length))+
geom_col()
Bar
Created on 2019-02-05 by the reprex package (v0.2.1)
Thanks!
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.
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: https://www.r-graph-gallery.com/stacked-barplot/
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.