# Choosing Colors and Legend in AlgebraOfGraphics

**URL:** https://discourse.julialang.org/t/choosing-colors-and-legend-in-algebraofgraphics/82152
**Category:** Visualization
**Tags:** makie, algebraofgraphics
**Created:** [June 2, 2022, 8:49pm UTC](https://discourse.julialang.org/t/choosing-colors-and-legend-in-algebraofgraphics/82152 "2022-06-02T20:49:31Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)
#### Post date: [June 2, 2022, 8:49pm UTC](https://discourse.julialang.org/t/choosing-colors-and-legend-in-algebraofgraphics/82152/1 "2022-06-02T20:49:32Z")

</div>

I’m trying to create a plot comparing two parameters I calculated in Turing.jl. I’ve kind of managed this with the following code:

```julia
data(avg_vote) * aog.density() * mapping(
    :avg_vote=>"House Popular Vote: Average Democratic Share"; 
    color=:post_1994=>"Before and After 1994"
) |> draw

```

 ![download](https://global.discourse-cdn.com/julialang/original/3X/a/2/a24ce65111eaa1707269fa79570f6971d0e36ed3.png)

Hoever, I can’t figure out how to make edits to this. I’d prefer it if “Before” showed up first in the legend, and I’d like the two groups to be colored red and blue. How would I go about this?

---

<div class="post-metadata">

### Author: ![Storopoli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/storopoli/32/209278_2.png) [@Storopoli](https://discourse.julialang.org/u/Storopoli)
#### Post date: [June 2, 2022, 9:44pm UTC](https://discourse.julialang.org/t/choosing-colors-and-legend-in-algebraofgraphics/82152/2 "2022-06-02T21:44:39Z")

</div>

Try:

1. Make the layer and assign to an object:

2. Call `draw` on that layer with the `palettes` keyword argument:

---

<div class="post-metadata">

### Author: ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)
#### Post date: [June 2, 2022, 10:09pm UTC](https://discourse.julialang.org/t/choosing-colors-and-legend-in-algebraofgraphics/82152/4 "2022-06-02T22:09:55Z")

</div>

That fixed the colors problem, thank you! Now I just need to figure out how to switch the order in the legend.

EDIT: Found the answer [here](http://juliaplots.org/AlgebraOfGraphics.jl/dev/gallery/gallery/customization/legend/)!

---

<div class="post-metadata">

### Author: ![Storopoli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/storopoli/32/209278_2.png) [@Storopoli](https://discourse.julialang.org/u/Storopoli)
#### Post date: [June 3, 2022, 7:55pm UTC](https://discourse.julialang.org/t/choosing-colors-and-legend-in-algebraofgraphics/82152/5 "2022-06-03T19:55:27Z")

</div>

Great, it was a busy week. I was planning to get to your answer later. Glad you managed to find it!
