Я пытаюсь уменьшить расстояние между барами уже, однако position_dodge, похоже, не работает при настройке расстояния между полосками.ggplot geom_bar с position_dodge НЕ регулирует расстояние между барами
Ниже приведен мой пример кода с двумя выходами с различной шириной один с 0,7 и один с 5, но ширина между решеткой не влияет ...:
library(ggplot2)
library(grid)
library(ggthemes)
library(scales)
library(gridExtra)
variables = c('a','b','c','d','e')
values = c(0.2,0.4,0.6,0.8,1.0)
std = c(0.05,0.06,0.03,0.08,0.09)
Data = data.frame(variables, values, std)
f3 = ggplot(data = Data, aes(x = variables, y = values, group = variables)) +
geom_bar(stat='identity',width=0.6,position=position_dodge(width = 0.7),fill=c('#FF7F0E','#2CA02C','#D62728', '#00008B', '#B23AEE')) +
coord_flip() +
geom_errorbar(aes(ymin=values-std, ymax=values+std),
width=.2,size=0.3) +
scale_y_continuous("Variable Importance", expand = c(0,0),limits = c(0, 1.1), breaks=seq(0, 1.1, by = 0.1)) + # rescale Y axis slightly
scale_x_discrete("Variables", limits = c('a','b',"c","d","e")) +
theme_bw() + # make the theme black-and-white rather than grey (do this before font changes, or it overrides them)
theme(
line = element_line(size=0.3),
plot.title = element_blank(), # use theme_get() to see available options
axis.title.x = element_text(family='sans',size=13),
axis.title.y = element_text(family='sans',size=13, angle=90),
axis.text.x = element_text(family='sans',vjust=0.4,size=11),
axis.text.y = element_text(family='sans',size=11),
panel.grid.major = element_blank(), # switch off major gridlines
panel.grid.minor = element_blank(), # switch off minor gridlines
legend.position = 'none', # manually position the legend (numbers being from 0,0 at bottom left of whole plot to 1,1 at top right)
legend.title = element_blank(), # switch off the legend title
legend.text = element_blank(),
legend.key.size = unit(1.5, "lines"),
legend.key = element_blank(), # switch off the rectangle around symbols in the legend
panel.border=element_blank(),
axis.line=element_line(size=0.3)
)
plot(f3)
Любая помощь будет принята с благодарностью! Спасибо,
Я хотел бы предложить 'geom_pointrange' для представления такого рода данных. –
Почему у вас есть аргумент 'width = 0.6' в' geom_bar() ', это без: http://prntscr.com/89m3ah – user2673238
@Gregor Ответ на ваш вопрос на самом деле. Возможно, это может быть ответ? – tonytonov