I tried a bar plot using the below codes (apologies for bad codes, I'm not a pro). I want the text inside the bar to start from the extreme left (from the y-axis).
Thank you .
library(tidyverse)
library(ggrepel)
library(ggfittext)
library(RColorBrewer)
library(ggthemes)
hours <- c("2 hrs", "2 hrs", "2 hrs", "2 hrs",
"4 hrs", "4 hrs", "6 hrs")
plan <- tribble(
~hrs, ~task,
8, "Data viz using ggplot2",
6, "Dynamic docs using r markdown",
6, "Practice exercises",
4, "Intro to R & RStudio",
4, "Citations using citr",
4, "Tables using gt",
4, "Slides using xaringan"
)
plan %>%
mutate(task = fct_reorder(task, hrs)) %>%
ggplot(aes(hrs, task, fill = task)) +
geom_col(stat="identity", alpha=.6, width=.7) +
scale_fill_brewer(palette = "Set2") +
theme_tufte() +
geom_text(aes(label=task),
hjust = 0.95,
size = 7) +
labs(
title = "Topics you will learn",
x = "",
y = ""
) +
theme(
plot.title = element_text(size = 25, hjust = 0.5),
legend.position = "none",
axis.text.y = element_text(size = 25),
axis.text.x = element_blank(),
axis.ticks.x = element_blank()) +
scale_y_discrete(labels= hours) +
annotate("rect", xmin = 4.5, xmax = 8.5, ymin = 0.7, ymax = 2.8, color = "white", fill= "orange") +
annotate("text", x = 6.5, y = 2.50, label = c("Total 11 sessions"), size = 7, color = "white", fontface=2) +
annotate("text", x = 6.5, y = 2.00, label = c("7pm to 9pm IST"), size = 7, color = "white", fontface=2) +
annotate("text", x = 6.5, y = 1.50, label = c("Tue - Thur - Sat"), size = 7, color = "white", fontface=2) +
annotate("text", x = 6.5, y = 1.00, label = c("Sept 5 - 29, 2020"), size = 7, color = "white", fontface=2)