What I've generated so far..... [
VERSUS
What needs to be recreated [
my code so far:
Recreated_figure_DHRP %>%
ggplot(aes(x = Insurers, y =`INR BN`,fill = FY,group=FY))
geom_bar(stat = "identity", position = position_dodge(), alpha = 0.75,)
theme(axis.text.x = element_text(angle = 60, hjust = 1))
theme(legend.position="top")
ylim(0,400)
geom_text(aes(label = `INR BN`), fontface = "bold", vjust = 1.5,
position = position_dodge(.9), size = 2.25)
CodePudding user response:
Additional data can be added with suitable geom_XYZ
functions, overwriting the aes
values that change from the ggplot
call. So for this case adding the line is as follows:
Recreated_figure_DHRP <- read.csv("C:\Users\te01\Downloads\Dataframe - sheet1.csv")
Recreated_figure_DHRP %>%
ggplot(aes(x = Insurers, y =`INR.BN`,fill = FY,group=FY))
geom_bar(stat = "identity", position = position_dodge(), alpha = 0.75,)
theme(axis.text.x = element_text(angle = 60, hjust = 1))
theme(legend.position="top")
ylim(0,400)
geom_text(aes(label = `INR.BN`), fontface = "bold", vjust = 1.5,
position = position_dodge(.9), size = 2.25)
geom_line(aes(y=`YOY.Growth`), col="red")
(note very slight differences in the dataframe column names)
That gives:
CodePudding user response:
You can use geom_rect
function to highlight the specific regions of the plot.
Recreated_figure_DHRP %>%
ggplot(aes(x = Insurers, y =`INR.BN`,fill = FY,group=FY))
geom_bar(stat = "identity", position = position_dodge(), alpha = 0.75)
geom_rect(data = Recreated_figure_DHRP %>% filter(Insurers == "GoDigit"),
aes(xmin = Insurers,
xmax = Insurers,
ymin = 0,
ymax = max(`INR.BN`)),
color = "red",
fill = NA,
linetype = 2,#dashed line
alpha = 0.5,
show. Legend = FALSE)
geom_text(aes(label = `INR.BN`),
fontface = "bold",
vjust = 1.5,
position = position_dodge(.9),
size = 2.25)
geom_line(aes(y=`YOY.Growth`), col="red")
ylim(0,400)
theme(axis.text.x = element_text(angle = 60, hjust = 1),
legend. Position="top")