# Is there a simple way to differentiate multiple lines with sparse markers?

**URL:** <https://discourse.julialang.org/t/is-there-a-simple-way-to-differentiate-multiple-lines-with-sparse-markers/115307>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [June 7, 2024, 3:23am UTC](https://discourse.julialang.org/t/is-there-a-simple-way-to-differentiate-multiple-lines-with-sparse-markers/115307 "2024-06-07T03:23:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lionisxn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lionisxn/32/37989_2.png) [@lionisxn](https://discourse.julialang.org/u/lionisxn)\
**Post date:** [June 7, 2024, 3:23am UTC](https://discourse.julialang.org/t/is-there-a-simple-way-to-differentiate-multiple-lines-with-sparse-markers/115307/1 "2024-06-07T03:23:10Z")

</div>

Hi, I have a multiple-line plot like this  
 ![微信截图_20240607111736](https://global.discourse-cdn.com/julialang/original/3X/8/9/8901b5091b016e9745cfcbc947467e34cec7899e.jpeg)  
The figure is ugly owing to the unnecessary markers for each data point. How can I differentiate the two lines with less markers?

---

<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 7, 2024, 4:27am UTC](https://discourse.julialang.org/t/is-there-a-simple-way-to-differentiate-multiple-lines-with-sparse-markers/115307/2 "2024-06-07T04:27:20Z")

</div>

Which plotting package are you using? The simplest solution would be to superpose

- a line plot with all the points
- a scatter plot with a subset of the points (like every fourth one)

---

<div class="post-metadata">

**Author:** ![lionisxn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lionisxn/32/37989_2.png) [@lionisxn](https://discourse.julialang.org/u/lionisxn)\
**Post date:** [June 7, 2024, 5:55am UTC](https://discourse.julialang.org/t/is-there-a-simple-way-to-differentiate-multiple-lines-with-sparse-markers/115307/3 "2024-06-07T05:55:13Z")

</div>

Hi, gdalle, I am using Plots with Plots.GRBackend(). I tried to use “scatter” inspired by your suggestion, but superfluous legends will show like this:  
 ![微信截图_20240607111736](https://global.discourse-cdn.com/julialang/original/3X/3/5/3599c1137439772d57887a2bb451ad9a55a5d0eb.jpeg)  
It is much like what I desire except for the superfluous legend

---

<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 7, 2024, 6:02am UTC](https://discourse.julialang.org/t/is-there-a-simple-way-to-differentiate-multiple-lines-with-sparse-markers/115307/4 "2024-06-07T06:02:27Z")

</div>

you can remove the labels for the two scatter plots, and ideally make them have the same color as the lines?

---

<div class="post-metadata">

**Author:** ![lionisxn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lionisxn/32/37989_2.png) [@lionisxn](https://discourse.julialang.org/u/lionisxn)\
**Post date:** [June 7, 2024, 6:23am UTC](https://discourse.julialang.org/t/is-there-a-simple-way-to-differentiate-multiple-lines-with-sparse-markers/115307/5 "2024-06-07T06:23:14Z")

</div>

I think I’ve got my problem solved by following the code like this:

> p = plot(…; label = nothing)  
> scatter!(p…)  
> It now outputs like this  
> ![微信截图_20240607111736](https://global.discourse-cdn.com/julialang/original/3X/a/a/aa84de4eb76a33c96f37e266458fc6a14e2217cc.jpeg)

---

<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 7, 2024, 6:25am UTC](https://discourse.julialang.org/t/is-there-a-simple-way-to-differentiate-multiple-lines-with-sparse-markers/115307/6 "2024-06-07T06:25:53Z")

</div>

Sure, but you could also provide `label = nothing` on the other two curves.

---

<div class="post-metadata">

**Author:** ![lionisxn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lionisxn/32/37989_2.png) [@lionisxn](https://discourse.julialang.org/u/lionisxn)\
**Post date:** [June 7, 2024, 6:31am UTC](https://discourse.julialang.org/t/is-there-a-simple-way-to-differentiate-multiple-lines-with-sparse-markers/115307/7 "2024-06-07T06:31:28Z")

</div>

That is cool! The codes are more concise !
