【问题标题】:fixing bar size with ggplot in facet_grid()在 facet_grid() 中使用 ggplot 修复条形大小
【发布时间】:2019-12-18 10:57:37
【问题描述】:

我正在尝试使用此代码制作相同大小的绘图条:

my_plot_replicas = (ggplot(df)         
+ aes(x='algorithm',y='replicas',fill='algorithm') 
+ geom_col(position=position_dodge2(preserve='single'))
+ geom_errorbar(aes(ymin='replicas-error', ymax='replicas+error'), 
width=.2,position=position_dodge(.9))
+ facet_grid('mobility ~ time_elapsed',scales = "free_x")
+ scale_fill_manual(["darkgray", "gray"])
)

但是我得到了这个图,其中单独的条占据了网格的整个宽度:

我希望第 0 列和第 43200 列中的条与其他条的大小相同,这可能吗?

【问题讨论】:

  • 你为什么用python标记?
  • 尝试删除scales = "free_x" 选项。
  • @PoGibas 因为我在python中使用的是plotnine,在实现上存在一些差异。
  • @AHart 如果我删除 scales = "free_x" 那么我得到两个 x 标签(输入,输出),即使输出/输入在某些列中没有值,所以这些情况的空间保持为空。我不想那样。
  • 我想要第 7 个图中 stackoverflow.com/questions/38101512/… 中显示的内容。但由于某种原因,它不适用于我的 plotnine。

标签: python ggplot2 facet-grid plotnine geom-col


【解决方案1】:

根据 plotnine 文档

空格:str in ['fixed', 'free', 'free_x', 'free_y'] 面板的 x 或 y 侧是否应具有大小。它还取决于 scales 参数。默认为“固定”。尚不支持此设置。 plotnine.facets.facet_grid

【讨论】:

    猜你喜欢
    • 2020-07-04
    • 1970-01-01
    • 2020-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多