2

I am starting to program in Julia.

I would like to know how to put the corresponding name in the scatter for each country. I am using only the Plots.jl package, below is a screenshot of what I have done.

Any help is appreciated !!!

Code

Pratap Alok Raj
  • 1,098
  • 10
  • 19

1 Answers1

4

Use the series_annotations property. See the code below.

julia> using DataFrames, Random, Plots

julia> df = DataFrame(x=rand(8),y=rand(8),label=[randstring(6) for _ in 1:8])
8×3 DataFrame
 Row │ x         y          label
     │ Float64   Float64    String
─────┼─────────────────────────────
   1 │ 0.436953  0.307696   YVFnr8
   2 │ 0.269204  0.303321   Rpsbz5
   3 │ 0.120839  0.870337   TEHjOf
   4 │ 0.329191  0.893599   9cERmd
   5 │ 0.484566  0.852965   wn379M
   6 │ 0.743256  0.856181   RW1AjF
   7 │ 0.857837  0.0873707  YpdRO2
   8 │ 0.668681  0.414274   gJ4HLw

julia> scatter(df.x, df.y, series_annotations = text.(df.label, :bottom))

enter image description here

Przemyslaw Szufel
  • 40,002
  • 3
  • 32
  • 62
  • When I try to replace the code, the graph moves and everything disappears. Do you know why? https://i.stack.imgur.com/X3lj3.png – Begginner Julia Jun 01 '21 at 00:13