Reputation: 741
I would like to visualize my dataframe with a simple bar plot using coord_polar.I am trying to reproduce this screenshot:
Here is my try:
p <- ggplot(data=df, aes(x=Month, y=Percent)) +
geom_col(aes(fill= Month ), width = 0.87 )+
coord_polar()+
labs(title="some title ",
subtitle="% of total number of something",
x="",
y="",
caption="Reaserch")+
theme_minimal(10) +
theme(legend.position = "none",
text=element_text(family="Courier"),
plot.title=element_text(size=12, hjust=0.2, face='bold'),
plot.subtitle=element_text(size=11, hjust=0.2),
axis.text.x = element_text(size=12, hjust=0.1, face='bold'),
axis.title.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks.y = element_blank())
I would like to remove background grid and top left axis and show month and value for each record inside the pie (ex. Aug 68%) + where is the right place to define color = "Yellow"
?
# reproducible sample data
df <- tibble::tribble(
~Month, ~Percent,
"Jan", 68,
"Feb", 68,
"Mar", 68,
"Apr", 68,
"May", 68,
"June", 65,
"July", 52,
"Aug", 60,
"Sept", 68,
"Oct", 68,
"Nov", 68,
"Dec", 68
)
Upvotes: 0
Views: 1834
Reputation: 66490
df$Month_label = paste0(df$Month, "\n", df$Percent, "%") %>% fct_inorder
ggplot(data=df, aes(x=Month_label, y=Percent)) +
geom_col(fill = "#ffc97b", width = 0.87 )+
geom_text(aes(label = Month_label, y = Percent - 10)) +
coord_polar()+
labs(title="some title ",
subtitle="% of total number of something",
x="",
y="",
caption="Research")+
theme_minimal(10) +
theme(legend.position = "none",
axis.text = element_blank(),
text=element_text(family="Courier"),
plot.title=element_text(size=12, hjust=0.2, face='bold'),
plot.subtitle=element_text(size=11, hjust=0.2),
panel.grid = element_blank(),
axis.ticks.y = element_blank())
Upvotes: 4