# Ggplot style background in Gadfly

**URL:** <https://discourse.julialang.org/t/ggplot-style-background-in-gadfly/9722>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [March 14, 2018, 9:57pm UTC](https://discourse.julialang.org/t/ggplot-style-background-in-gadfly/9722 "2018-03-14T21:57:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yifan\_Liu](https://avatars.discourse-cdn.com/v4/letter/y/4da419/32.png) [@Yifan\_Liu](https://discourse.julialang.org/u/Yifan_Liu)\
**Post date:** [March 14, 2018, 9:57pm UTC](https://discourse.julialang.org/t/ggplot-style-background-in-gadfly/9722/1 "2018-03-14T21:57:08Z")

</div>

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

 ![Rplot](https://global.discourse-cdn.com/julialang/original/3X/3/f/3fe17fb8a400158af4fdd76b742e9d35a73def98.png)

---

<div class="post-metadata">

**Author:** ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)\
**Post date:** [March 15, 2018, 10:00am UTC](https://discourse.julialang.org/t/ggplot-style-background-in-gadfly/9722/2 "2018-03-15T10:00:53Z")

</div>

An example:

```julia
# 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](http://gadflyjl.org/stable/man/themes.html)

---

<div class="post-metadata">

**Author:** ![Yifan\_Liu](https://avatars.discourse-cdn.com/v4/letter/y/4da419/32.png) [@Yifan\_Liu](https://discourse.julialang.org/u/Yifan_Liu)\
**Post date:** [March 15, 2018, 6:27pm UTC](https://discourse.julialang.org/t/ggplot-style-background-in-gadfly/9722/3 "2018-03-15T18:27:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)\
**Post date:** [March 15, 2018, 6:56pm UTC](https://discourse.julialang.org/t/ggplot-style-background-in-gadfly/9722/4 "2018-03-15T18:56:11Z")

</div>

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

```julia
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](https://global.discourse-cdn.com/julialang/original/3X/3/0/308849685f58faabc4b1a5b7121ab04476cff2d9.png)

---

<div class="post-metadata">

**Author:** ![Yifan\_Liu](https://avatars.discourse-cdn.com/v4/letter/y/4da419/32.png) [@Yifan\_Liu](https://discourse.julialang.org/u/Yifan_Liu)\
**Post date:** [March 15, 2018, 7:00pm UTC](https://discourse.julialang.org/t/ggplot-style-background-in-gadfly/9722/5 "2018-03-15T19:00:01Z")

</div>

That is exactly what I want!

---

<div class="post-metadata">

**Author:** ![tlnagy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlnagy/32/5815_2.png) [@tlnagy](https://discourse.julialang.org/u/tlnagy)\
**Post date:** [March 16, 2018, 8:31pm UTC](https://discourse.julialang.org/t/ggplot-style-background-in-gadfly/9722/6 "2018-03-16T20:31:23Z")

</div>

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