# Grouping for color or markers in CairoMakie

**URL:** <https://discourse.julialang.org/t/grouping-for-color-or-markers-in-cairomakie/56728>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [March 8, 2021, 12:31pm UTC](https://discourse.julialang.org/t/grouping-for-color-or-markers-in-cairomakie/56728 "2021-03-08T12:31:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vjd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vjd/32/2644_2.png) [@vjd](https://discourse.julialang.org/u/vjd)\
**Post date:** [March 8, 2021, 12:31pm UTC](https://discourse.julialang.org/t/grouping-for-color-or-markers-in-cairomakie/56728/1 "2021-03-08T12:31:59Z")

</div>

is there a way to groupby a dataframe column passed into `color` or `marker` such that each group gets a unique element? or does this have to be done as different `scatter!` calls for each group

```nohighlight
ccf = DataFrame(a = 1:4, 
                b = 1:4, 
                c = ["low", "low", "high", "high"])

fig = default_figure()
ax2 = fig[1, 1] = Axis(fig, title = "test")
scat1 = scatter!(ax2, ccf.a,ccf.b, color= :red)
fig

```

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [March 8, 2021, 2:19pm UTC](https://discourse.julialang.org/t/grouping-for-color-or-markers-in-cairomakie/56728/2 "2021-03-08T14:19:43Z")

</div>

Are you looking for something like this:

```julia
using DataFrames, GLMakie, ColorSchemes

ccf = DataFrame(a = 1:4, 
                b = 1:4, 
                c = ["low", "low", "high", "high"])

palette = ColorSchemes.tab10.colors

color_indices = groupindices(groupby(ccf, :c))
scatter(ccf.a, ccf.b, color=palette[color_indices])

```

---

<div class="post-metadata">

**Author:** ![vjd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vjd/32/2644_2.png) [@vjd](https://discourse.julialang.org/u/vjd)\
**Post date:** [March 8, 2021, 2:29pm UTC](https://discourse.julialang.org/t/grouping-for-color-or-markers-in-cairomakie/56728/3 "2021-03-08T14:29:12Z")

</div>

yes. Thank you.

---

<div class="post-metadata">

**Author:** ![vjd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vjd/32/2644_2.png) [@vjd](https://discourse.julialang.org/u/vjd)\
**Post date:** [March 8, 2021, 2:30pm UTC](https://discourse.julialang.org/t/grouping-for-color-or-markers-in-cairomakie/56728/4 "2021-03-08T14:30:52Z")

</div>

is there a collection of `marker`’s that can be accessed like the color palette?

---

<div class="post-metadata">

**Author:** ![mike](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike/32/39_2.png) [@mike](https://discourse.julialang.org/u/mike)\
**Post date:** [March 8, 2021, 2:42pm UTC](https://discourse.julialang.org/t/grouping-for-color-or-markers-in-cairomakie/56728/5 "2021-03-08T14:42:54Z")

</div>

`marker`, like `color`, can also be a vector rather than a scalar, so

```julia
marker_indices = groupindices(groupby(ccf, :c))
marker = ['↓', '↑']
scatter(ccf.a, ccf.b, marker = marker[marker_indices])

```

should work. Though there doesn’t seem to be a “marker palette”-like collection.

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [March 8, 2021, 2:50pm UTC](https://discourse.julialang.org/t/grouping-for-color-or-markers-in-cairomakie/56728/6 "2021-03-08T14:50:32Z")

</div>

see here:

> [@MarkerElement allowable shapes](https://discourse.julialang.org/t/markerelement-allowable-shapes/56356/2):
>
> MarkerElement is just using Scatter, so all markers that work with that can be used. In general, the way it works currently is that any character within Dejavu Sans, which is hardcoded as the Scatter font, can be used. [Here is a list of additional symbols](https://github.com/JuliaPlots/AbstractPlotting.jl/blob/5db0c94b368089e492f53fd8b706806623a8af46/src/conversions.jl#L1040-L1061) that have been overloaded and are just converted to certain characters. As far as I can see, these are not documented anywhere, though. There are tons of Unicode symbols that are useful as markers beyond that small set.

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [March 8, 2021, 2:52pm UTC](https://discourse.julialang.org/t/grouping-for-color-or-markers-in-cairomakie/56728/7 "2021-03-08T14:52:43Z")

</div>

And it looks like the default list is in `AbstractPlotting.default_palettes.marker`.
