# Control on density plot marker shape and color

**URL:** https://discourse.julialang.org/t/control-on-density-plot-marker-shape-and-color/124846
**Category:** Visualization
**Tags:** statsplots
**Created:** [January 16, 2025, 7:05pm UTC](https://discourse.julialang.org/t/control-on-density-plot-marker-shape-and-color/124846 "2025-01-16T19:05:53Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Nick1](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@Nick1](https://discourse.julialang.org/u/Nick1)
#### Post date: [January 16, 2025, 7:05pm UTC](https://discourse.julialang.org/t/control-on-density-plot-marker-shape-and-color/124846/1 "2025-01-16T19:05:54Z")

</div>

I am trying to plot different probability densities on the same plot from a data frame, based on a group. However, there is an overlap on the lines and I need to use different marker shapes and colors for better visibility. How can I have control of it? I am using the following command:

```julia
@df total density(:ProteinA, group = (:Type), legend = :topright,

xtickfontsize=15,ytickfontsize=15,guidefontsize=19, legendfontsize = 14, size=(900,800), linewidth=3,

xlimits=(low=0.0))

```

Thank you

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [January 19, 2025, 10:43am UTC](https://discourse.julialang.org/t/control-on-density-plot-marker-shape-and-color/124846/2 "2025-01-19T10:43:15Z")

</div>

With StatsPlots.jl it is possible to change the marker styles and/or the line styles in the density plots:

 ![StatsPlots_density_marker_types_and_line_widths](https://global.discourse-cdn.com/julialang/original/3X/6/d/6d6e894fe71edc772898becb5a9d49f1e2d85b05.jpeg)

However, for the scatter series type, AFAIK there seems to be no way to control the minimum spacing between the markers (see also [this post](https://discourse.julialang.org/t/is-there-a-simpler-way-to-plot-less-points/75786/6)).

---

<div class="post-metadata">

### Author: ![Nick1](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@Nick1](https://discourse.julialang.org/u/Nick1)
#### Post date: [January 21, 2025, 12:00am UTC](https://discourse.julialang.org/t/control-on-density-plot-marker-shape-and-color/124846/3 "2025-01-21T00:00:23Z")

</div>

Thank you for your answer! However, It is unclear how to pick the marker style for each group separately from the documentation. I tried to do it that way:

```julia
@df total density(:ProteinA, group = (:Type), legend = :topright,
xtickfontsize=15,ytickfontsize=15,guidefontsize=19, legendfontsize = 14, size=(900,800), linewidth=3,
xlimits=(0.0, Inf), marker = (:circle, :diamond, :square, :rect, :cross, :xcross, :octagon))

```

but I get the following warning:

```julia
┌ Warning: Skipped marker arg diamond.
└ @ Plots C:\Users\memmo\.julia\packages\Plots\Ec1L1\src\args.jl:1149
┌ Warning: Skipped marker arg square.
└ @ Plots C:\Users\memmo\.julia\packages\Plots\Ec1L1\src\args.jl:1149
┌ Warning: Skipped marker arg rect.
└ @ Plots C:\Users\memmo\.julia\packages\Plots\Ec1L1\src\args.jl:1149
┌ Warning: Skipped marker arg cross.
└ @ Plots C:\Users\memmo\.julia\packages\Plots\Ec1L1\src\args.jl:1149
┌ Warning: Skipped marker arg xcross.
└ @ Plots C:\Users\memmo\.julia\packages\Plots\Ec1L1\src\args.jl:1149
┌ Warning: Skipped marker arg octagon.
└ @ Plots C:\Users\memmo\.julia\packages\Plots\Ec1L1\src\args.jl:1149

```

As for the spacing, it might be an issue I will need to resolve

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [January 21, 2025, 7:12am UTC](https://discourse.julialang.org/t/control-on-density-plot-marker-shape-and-color/124846/4 "2025-01-21T07:12:47Z")

</div>

In Plots.jl / StatsPlots.jl, if you have 3 groups like in my example you usually pass plot attributes as a 3 element row matrix, or as a scalar if it applies to all groups.

For my scatter plot example, I used:

```julia
msw=0.3, lw=0, marker=[:circle :utriangle :square], mc=[:red :lime :cyan]

```
