Here is a barchart where values are too big/small. Therefore, it seems that truncation happens depending on vjust used
geom_text(aes(label = paste(sprintf("%.1f", importance), "%"), y= importance), vjust = 0 or +/- 1)
However, can there be an option where the value always visible without truncation ?
library(tidyverse)
library(drlib)
viz <- data.frame(type = c(rep("A",5),rep("B",4)),
project = c("ABC","BCD","CDE","EFG","FGI","GIK","IKL","KLM","LMO"),
complexity = c(.8,.95,.6,.8,.9,.3,.7,.01,.6),
impact = c(1,.8,.7,.8,.9,.4,.8,.6,.5),
relevance = c(.8,.5,.7,.9,.1,.8,.7,.7,100),
stringsAsFactors = F)
#viz[,3:5] <- map(viz[,3:5], scales::percent)
viz_lng <- viz %>%
gather(-c(1,2), key = category, value = importance)%>%
arrange(desc(importance))
ggplot(viz_lng[which(viz_lng$importance>0),],
aes(x = reorder_within(project, importance, category, ),
y= importance, group = project, fill = project)) +
geom_bar(stat="identity") +
xlab("Projects") +
ggtitle("Project priority") +
geom_text(aes(label = paste(sprintf("%.1f", importance), "%"), y= importance), vjust = -.1) +
#geom_text(aes(label = paste(sprintf("%.1f", importance), "%"), y= importance), vjust = 0) +
scale_x_reordered() +
facet_wrap(vars(category,type), scales="free", ncol = 2) +
guides(fill=FALSE) + theme_bw() +
theme(strip.text = element_text(size = 14),
axis.text.x = element_text(angle = 45, hjust = 1),
legend.title = element_blank(),
axis.text = element_text(size = 14),
axis.title = element_text(size = 14))