# Color of the marker to be read from a dictionary

**URL:** <https://discourse.julialang.org/t/color-of-the-marker-to-be-read-from-a-dictionary/100569>\
**Category:** New to Julia\
**Tags:** plotting\
**Created:** [June 19, 2023, 5:55pm UTC](https://discourse.julialang.org/t/color-of-the-marker-to-be-read-from-a-dictionary/100569 "2023-06-19T17:55:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fatemeh\_haddadi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fatemeh_haddadi/32/50868_2.png) [@fatemeh\_haddadi](https://discourse.julialang.org/u/fatemeh_haddadi)\
**Post date:** [June 19, 2023, 5:55pm UTC](https://discourse.julialang.org/t/color-of-the-marker-to-be-read-from-a-dictionary/100569/1 "2023-06-19T17:55:39Z")

</div>

I have a dictionary (Y) and I want to plot its values using scatter(x,y).  
What I want is for the colors of the markers to be either blue or red (or any other two colors) corresponding to 0 and 1 read from another dictionary with the same keys.

Let’s say as a simple example:

```julia
Y = Dict("A" => 15, "B" => 20, "C" => 45)
Z = Dict("A" => 0 , "B" => 1, "C" => 0)

```

This is what I have so far:

```julia
using Plots
X= 1:length(Y)
p=scatter(X, [values(Y)...];color= [values(Z)...])

```

but the colors don’t match the values in z dictionary.

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [June 19, 2023, 6:08pm UTC](https://discourse.julialang.org/t/color-of-the-marker-to-be-read-from-a-dictionary/100569/2 "2023-06-19T18:08:33Z")

</div>

That’s probably because the order of keys and values in a dictionary is not guaranteed. Judging by your example it’s unclear what you need the keys for, but the secret is to always iterate over a predefined vector of keys to get the associated values in the same order.

---

<div class="post-metadata">

**Author:** ![fatemeh\_haddadi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fatemeh_haddadi/32/50868_2.png) [@fatemeh\_haddadi](https://discourse.julialang.org/u/fatemeh_haddadi)\
**Post date:** [June 19, 2023, 6:11pm UTC](https://discourse.julialang.org/t/color-of-the-marker-to-be-read-from-a-dictionary/100569/3 "2023-06-19T18:11:55Z")

</div>

I see.  
The keys are only used as the xticks of the plot.  
OK I try iteration over the keys. Thanks you
