I have built this graph in R:
library(ggplot2)
dataset <- data.frame(Riserva_Riv_Fine_Periodo = 1:10 * 10^6 + 1,
Anno = 1:10)
ggplot(data = dataset,
aes(x = Anno,
y = Riserva_Riv_Fine_Periodo)) +
geom_bar(stat = "identity",
width=0.8,
position="dodge") +
geom_text(aes( y = Riserva_Riv_Fine_Periodo,
label = round(Riserva_Riv_Fine_Periodo, 0),
angle=90,
hjust=+1.2),
col="white",
size=4, position = position_dodge(0.9))
As you can see I have 2 issue:
- the numbers into the bars are truncated.
- The y scale is written in this format "0e+00"
I'd like to:
- Set the numbers inside or outside the bar according to the height of the bar
- Set the y scale in million.
ifelse
statement to conditionally change the hjust argument based on the value of the yscipen
option.Here is an example: