GiovineItalia / Gadfly.jl

Crafty statistical graphics for Julia.
http://gadflyjl.org/stable/
Other
1.9k stars 250 forks source link

Space between groups in grouped bar chart #1092

Open IgorDouven opened 6 years ago

IgorDouven commented 6 years ago

I know that, in general, the space between bars in a bar plot can be controlled via bar_spacing. But in a grouped bar chart, is there a way to define one spacing for the bars within each group and another for the groups?

bjarthur commented 6 years ago

hah, i didn't know about bar_spacing. though it's documented for theme, would be nice to have an example in Geom.bar.

relevant code is here if you want to take a stab at adding different spacings between groups.

IgorDouven commented 6 years ago

I saw this, but I'm hoping there's an easier solution.

tlnagy commented 6 years ago

Do you know how ggplot2 handles this?

IgorDouven commented 6 years ago

In ggplot2 one would use geom_bar(position="dodge", stat="identity") to create a grouped bar chart. That would automatically have spacing between the groups. To fine-tune the within-group spacing, one could use width and position_dodge within geom_bar(). In Gadfly, the only way I could get a grouped bar chart to look like I wanted was by specifying all individual xmin and xmax values. (I'm very satisfied with the result, though it would be nice if the creation of a grouped bar chart in Gadfly was as easy as it is in ggplot2.)

Mattriks commented 5 years ago

Another way to do a grouped bar chart is shown in this discourse posting: https://discourse.julialang.org/t/stacked-bar-graphs/18550/2

IgorDouven commented 5 years ago

Looks very nice! Many thanks for this!

Op za 22 dec. 2018 om 23:14 schreef Mattriks notifications@github.com:

Another way to do a grouped bar chart is shown in this discourse posting: https://discourse.julialang.org/t/stacked-bar-graphs/18550/2

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/GiovineItalia/Gadfly.jl/issues/1092#issuecomment-449600709, or mute the thread https://github.com/notifications/unsubscribe-auth/AgoBLMK-E5i8sQlhVuiKH95D8m5cq3H-ks5u7q6qgaJpZM4Rz_v2 .