r - Bar in Bar Chart with ggplot2 -
this question has answer here:
- how overlay 2 geom_bar? 1 answer
is possible plot bar in bar chart in r ggplot2 figure below. want compare expected , actual values , want generate figure similar figure below. have provided dummy code:
library(tidyverse) df = data_frame(name = letters[1:10],profit = rnorm(mean = 100, sd = 20, n = 10), target = profit + rnorm(mean = 10, sd = 10, n = 10)) df %>% ggplot(aes(x = name, y = profit)) + geom_bar(stat = "identity")
yes possible, @ ggplot documentation
library(tidyverse) df = data_frame(name = letters[1:10],profit = rnorm(mean = 100, sd = 20, n = 10), target = profit + rnorm(mean = 10, sd = 10, n = 10)) ggplot(df,aes(x=name,y=profit))+geom_bar(stat= "identity")+ geom_bar(aes(x= name,y=target),stat= "identity", width = 0.1,col = "green",fill="green")
Comments
Post a Comment