我fct_reorder()
用来在 ggplot 中排序我的因子的水平。这适用于个别地块。但是当我使用plot_grid()
from时cowplot
,出现了一些问题。相比之下,在左侧,我使用了一个具有固定因子水平的图,而不是使用fct_reorder
.
编辑:这是我正在使用的实际代码:
#make the base
myplot <-filter(summary_by_intensity_reshaped, str_detect(feature, "binary"), Frequency == "2Hz") %>%
ggplot(., aes(fct_reorder(feature, mean),mean,fill=Intensity, ymax=mean+sem, ymin=mean-sem))
#add the layers
myplot + geom_bar(stat="identity", position=position_dodge()) +
geom_errorbar(aes(width=0.2),position=position_dodge(0.9)) +
labs(x="Behavior",y="Percent of Trials (%)") +
scale_x_discrete(breaks=c("binary_flutter", "binary_hold", "binary_lift", "binary_jump","binary_rear", "binary_lick", "binary_guard", "binary_vocalize"), labels=c("Flutter", "Holding", "Lifting", "Jumping", "Rearing", "Licking", "Guarding", "Vocalizing"))+
facet_grid(~Frequency)+
theme(axis.text.x=element_text(angle=-90))
当我尝试在plot_grid()
. 那就是它呈现奇怪的时候,如下例所示。