How to make this plot in Julia?

It is possible with Plots.jl’s StatsPlots, but it should be easier:

using DataFrames, Random, StatsPlots
theme(:ggplot2)
default(dpi=600)

Random.seed!(123)
df = DataFrame(name = repeat(["A","B","C","D","E","F"], inner=4), 
      time=repeat([0,1,3,6], outer=6), value = rand(24))
#
dx, dy = extrema.((df.time, df.value))
dx, dy = 0.025 .* (dx[2] - dx[1], dy[2] - dy[1])
nam0 = first.(keys(groupby(df, :name)))
cdic = Dict(nam0 .=> palette(:default)[1:length(nam0)])
col0 = [cdic[x] for x in df.name]

@df df plot(:time, :value, marker=:circle, ms=3, group=:name, legend=:outertopright, legendtitle="name")
for (x,y,nm,c) in zip(df.time, df.value, df.name, col0)
    annotate!(x + rand((-dx,dx)), y + rand((-dy,dy)), (nm, 7, c))
end
Plots.current()

3 Likes