# How to label individuals dots in scatterplot?

**URL:** <https://discourse.julialang.org/t/how-to-label-individuals-dots-in-scatterplot/93791>\
**Category:** Visualization\
**Tags:** plots\
**Created:** [January 30, 2023, 8:34pm UTC](https://discourse.julialang.org/t/how-to-label-individuals-dots-in-scatterplot/93791 "2023-01-30T20:34:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Post date:** [January 30, 2023, 8:34pm UTC](https://discourse.julialang.org/t/how-to-label-individuals-dots-in-scatterplot/93791/1 "2023-01-30T20:34:32Z")

</div>

I want to scatter plto a bunch of dots, attaching a label to each. However, the `label` command gives the first label to each dot. Sample code:

```julia
using Plots
xs = [1,2,3]
ys = [2,4,6]
colors = [:red :blue :green]
labels = ["datapoint 1" "datapoint 2" "datapoint 2"]
scatter(xs,ys,color=colors,label=labels)

```

gives  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/3/a376cf7802b55caa6a10315469bf22d35141f0b5.png)

---

<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 30, 2023, 8:42pm UTC](https://discourse.julialang.org/t/how-to-label-individuals-dots-in-scatterplot/93791/2 "2023-01-30T20:42:30Z")

</div>

Check this [similar post](https://discourse.julialang.org/t/mark-each-scatter-point-uniquely/58803/4).

---

<div class="post-metadata">

**Author:** ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Post date:** [January 30, 2023, 8:51pm UTC](https://discourse.julialang.org/t/how-to-label-individuals-dots-in-scatterplot/93791/3 "2023-01-30T20:51:22Z")

</div>

That example is for setting numbers at the location of each scatter point, but I rather want a normal legend with labels in one corner, with one label for each dot.

---

<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 30, 2023, 8:54pm UTC](https://discourse.julialang.org/t/how-to-label-individuals-dots-in-scatterplot/93791/4 "2023-01-30T20:54:52Z")

</div>

In that simpler case, just transpose the input vectors:

```julia
scatter(xs', ys', color=colors, label=labels)

```

---

<div class="post-metadata">

**Author:** ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Post date:** [January 30, 2023, 9:01pm UTC](https://discourse.julialang.org/t/how-to-label-individuals-dots-in-scatterplot/93791/5 "2023-01-30T21:01:17Z")

</div>

That worked! Thanks a lot 🙂
