Gadfly.jl icon indicating copy to clipboard operation
Gadfly.jl copied to clipboard

How can I change the colors of bars of a bar plot? (No grouping)

Open NightMachinery opened this issue 4 years ago • 4 comments

Here is my plot:

display(plot(x=a, Geom.histogram(density=true, position=:dodge), Scale.x_discrete, Theme(
# bar_highlight=RGB(0,0.5,1),
 bar_spacing=3mm)))

image

I want to color the bars randomly, without affecting the plot otherwise. Sth like colorsame that gets a function index_of_current_element_in_color_group, group_default_color -> modified_color would be nice. This way I can introduce some noise into each color to make them visually more salient.

NightMachinery avatar Apr 19 '20 11:04 NightMachinery

I can't think of a way to do this with Geom.histogram, as you say the color aesthetic is used for grouping. If you calculated your own bins and counts e.g. using StatsBase, then you could use Geom.bar and color.

Mattriks avatar Apr 19 '20 23:04 Mattriks

I've started PR #1428 which adds new features to Geom.bar (and hence Geom.histogram). Feedback welcome!

Mattriks avatar Apr 27 '20 12:04 Mattriks

PR #1428 has been merged, so can this issue be closed?

Mattriks avatar Apr 30 '20 07:04 Mattriks

@Mattriks I think we should keep it. The alpha noise is a good alternative solution for this, but it’s not as visually appealing as changing the colors themselves.

NightMachinery avatar May 01 '20 13:05 NightMachinery