I have some code roughly like this:
df = DataFrame(
:percent_barrier => sqrt.(rand(100)) .* 100,
:stop_reason => ifelse.(rand(100) .> 0.75, "Solved", "Timeout")
df, x = "percent_barrier", color="stop_reason", Geom.histogram(;bincount = 10),
Gadfly.Guide.xlabel("Time spent solving barrier (10% bins)"),
Gadfly.Guide.ylabel("Amount of instances"),
Guide.colorkey(; title = "Stop reason")
Which generates the following image:
In R, I remember that I just needed to pass some object/flag for it to use grayscale and it was done. I am, however, not finding an easy answer for
Gadfly. There is some parameter that I can pass to any plot that use more colors than just black to make it grayscale?
no there is not an easy way. it is possible though to specify all the color defaults with a custom Theme. Gadlfy has two built-in “named” themes: Themes · Gadfly.jl. it would seem useful to have a greyscale theme too. care to submit a PR?
I have read the description of the
Gadfly.Theme, and it seems like more than I can handle right now, the following description of a field has also diminished my hopes:
A new Theme field, in development. Currently only works with Guide.manual_discrete_key and Guide.manual_color_key. (Function)
So I am not sure if the tools to implement a pervasive grayscale Theme exist currently.
The current way to change to a discrete gray scale for a single plot is:
plot(df, x = "percent_barrier", color="stop_reason",
Geom.histogram(;bincount = 10),
Changing colorscales via
Theme currently has some issues (see link in Theme_colormaps by Mattriks · Pull Request #1118 · GiovineItalia/Gadfly.jl · GitHub). But these changes are now being rolled out in other PRs (as you see noted with
discrete_colormap). The tables in the Gadfly Tutorial show the current status.