Ggplot style background in Gadfly

question

#1

I want to know how to get a ggplot style background in Gadfly, including the grey color and the grids, etc.


#2

An example:

# Can use Theme() or style()
ggplot_theme = Theme(panel_fill="gray90", grid_color="white")
# ggplot_theme = style(panel_fill=colorant"gray90", grid_color=colorant"white")

p = plot(x=1:5, y=rand(5), Geom.line, ggplot_theme)

If you want to use a Theme that you’ve created on a number of plots, then do e.g. Gadfly.push_theme(ggplot_theme)
For more info, see http://gadflyjl.org/stable/man/themes.html


#3

Thanks. How can I make the grid edge solid line instead of dot line?


#4

It seems grid_strokedash is missing from the docs, but type dump(Theme()) to see the full list.
And a new example:

using Colors, DataFrames, Gadfly, RDatasets
palette(n::Int) = LCHuv.(65, 100, 15:(360/n):374)
colscale = Scale.color_discrete(palette)
ggplot_theme = Theme(panel_fill="gray90", grid_color="white", grid_strokedash=[5mm, 0mm], discrete_color_scale=colscale)

p = plot(dataset("datasets","iris"), x=:PetalWidth, y=:SepalLength, color=:Species, Geom.point, ggplot_theme)

Iris


#5

That is exactly what I want!


#6

@Mattriks the real Gadfly guru to the rescue. Awesome plot!