I'm new to ggplot package so please excuse me if this is regarding basic matters
I've set up the code below but the labels of x-axis are messed up. It doesn't match with the data frame's data, rather randomized.
for the picture. I think Start_Profit comes first then ProductionCost and SalesCost.
Did I make missing sth important?
library(ggplot2)
plot_data <- data.frame(
items = c("Start_Profit","ProductionCost","SalesCost","End_Profit"),
diff = c(50,20,-30,40),
type = c("Net","Increase","Decrease","Net"),
start = c(0,50,70,40),
end = c(50,70,40,0)
)
plot_data$id <- seq_along(plot_data$diff)
ggplot(plot_data[1:3,], aes(fill = type)) + geom_rect(aes(x = items,
xmin=id-0.45, xmax=id+0.45,
ymin = end, ymax=start))