【发布时间】:2018-09-23 14:23:26
【问题描述】:
我正在为 ggplot 中的条形顺序而苦苦挣扎。为了简单起见:这是我用来创建情节的代码:
plot_data <- data() %>%
filter(Name %in% input$polymers)
print(plot_data)
ggplot(data = plot_data, aes(x = ID_Polymer, y = value), position = position_dodge(width = 1)) +
geom_bar(aes_string( fill=razeni()), position = position_dodge(width = 1), stat="identity", color="white")+
theme_minimal() +
theme(legend.text=element_text(size=21))+
theme(text = element_text(size=21))+
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +
ggtitle(input$title_text_box_id) +
labs(x = "", y = input$ylabel_text_box_id) +
geom_text(aes(x = ID_Polymer, y = value,Group=Polymer,label=value),
position = position_dodge(width = 1),vjust=2, size=5,colour = "white", fontface = "bold") +
scale_fill_tableau("Tableau 10")+
scale_x_discrete(labels=c(xpopisky()))#puts a reactive in x labels
fill 参数是反应性的,用户在闪亮的应用程序中选择。 结果如下所示:
我希望两个蓝色条和两个红色条并排,就像在这个帖子ggplot can not group bars
棘手的是,填充参数会随着来自闪亮应用程序的用户输入而改变,因此必须改变条形图的顺序。
类似:
aes_string(dodge = razeni()) 或 aes_string(order = razeni())
我希望这个问题很清楚,我很高兴收到有关如何处理它的任何建议。
【问题讨论】: