How to label individuals dots in scatterplot?

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:

using Plots
xs = [1,2,3]
ys = [2,4,6]
colors = [:red :blue :green]
labels = ["datapoint 1" "datapoint 2" "datapoint 2"]


Check this similar post.

1 Like

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.

In that simpler case, just transpose the input vectors:

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

That worked! Thanks a lot :slight_smile: