1

I'm trying to make the bars of the plot of the same size with this code:

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"])
)

But I get this plot, where the bars that are alone take the whole width of the grid:

enter image description here

I would like to have the bars from columns 0 and 43200 of the same size as the others, is that possible?

BlueMountain
  • 197
  • 2
  • 17
  • Why did you tag with python? – pogibas Dec 18 '19 at 11:36
  • Try removing the `scales = "free_x"` option. – AHart Dec 18 '19 at 13:27
  • @PoGibas Because I'm using plotnine in python and there are some differences in the implementation. – BlueMountain Dec 18 '19 at 14:54
  • @AHart if I remove scales = "free_x" then I get both x labels (in, out) even if out/in has no value in some columns so the space for those cases stays empty . I don't want that. – BlueMountain Dec 18 '19 at 14:56
  • I want what is shown in https://stackoverflow.com/questions/38101512/the-same-width-of-the-bars-in-geom-barposition-dodge in the 7th figure. But for some reason it is not working for me with plotnine. – BlueMountain Dec 18 '19 at 15:00
  • Got it. If you specify the same flexibility for facet width -- `space = "free_x"` -- are the bars still different widths? – AHart Dec 18 '19 at 16:26
  • With space = "free_x" what happens is that the y axis adjusts to each case, also not wanted. What do you mean by facet width? @AHart – BlueMountain Dec 18 '19 at 16:40
  • Really odd if true as space = "free_x" should only allow panels to have different widths and have no influence on y. From facet_grid documentation: "if "free_x" their width will be proportional to the length of the x scale... This setting has no effect unless the appropriate scales also vary." – AHart Dec 18 '19 at 18:45

1 Answers1

0

As per plotnine documentation

space : str in ['fixed', 'free', 'free_x', 'free_y'] Whether the x or y sides of the panels should have the size. It also depends to the scales parameter. Default is 'fixed'. This setting is not yet supported. plotnine.facets.facet_grid

GERMAN RODRIGUEZ
  • 397
  • 1
  • 4
  • 9