Ich möchte ein schwarz umrandetes Balkendiagramm mit Prozentangaben innerhalb der Bars erstellen. Ist das möglich von qplot? Ich bekomme die Prozentwerte angezeigt, aber sie sind nicht mit den einzelnen Balken ausgerichtet.Hinzufügen von Beschriftungen zu ggplot Balkendiagramm
Pakete: ggplot2, umformen
x <- data.frame(filename = c("file1", "file2", "file3", "file4"),
low = c(-.05,.06,.07,-.14),
hi = c(.87,.98,.56,.79))
x$tot <- x$hi + x$low
x <- melt(x, id = 'filename')
bar <- qplot(x = factor(filename),
y = value*100,
fill = factor(variable),
data = x,
geom = 'bar',
position = 'dodge') + coord_flip()
bar <- bar + scale_fill_manual(name = '',
labels = c('low',
'Hi',
"Tot"),
values = c('#40E0D0',
'#FF6347',
"#C7C7C7"))
bar <- bar + geom_text(aes(label = value*100))+geom_bar(colour = 'black')
bar <- bar + opts(panel.background = theme_rect(colour = NA))
bar <- bar + opts(legend.justification = 'bottom')
print(bar)
Willkommen zu SO. Da Sie Nicht-Base-R-Funktionen verwenden, fügen Sie bitte einen Verweis auf die Pakete hinzu, die zur Reproduktion Ihres Codes benötigt werden, d. H. 'Library (...)' – Andrie