【发布时间】:2019-12-13 17:12:13
【问题描述】:
我在 python 中使用 ggplot 和 plotnine,我有这段代码:
my_plot_availability = (ggplot(df)
+ aes(x='time_elapsed',y='mean',fill='policy')
+ geom_bar(position=position_dodge(),stat = "identity", color = "black",size = 0.5)
+ geom_errorbar(aes(ymin='mean-error', ymax='mean+error'), width=.2,position=position_dodge(.9))
+ facet_wrap('mobility')
+ scale_fill_manual(["darkgray", "gray"])
+ labs(x = "Time elpased [s]")
+ labs(y = "Mean content availability")
+ theme(element_text(family="Times",size=12))
)
绘制这个图:
而且我希望有相同大小的条形图,即使在某些情况下(例如案例 0)只有一个条形图。我知道我应该这样做:
position=position_dodge2(preserve='single')
但我在 python 中遇到以下错误:
NameError: name 'position_dodge2' is not defined
你知道怎么解决吗?
【问题讨论】:
标签: python ggplot2 geom-bar python-ggplot plotnine