# How to make this plot in Julia?

**URL:** <https://discourse.julialang.org/t/how-to-make-this-plot-in-julia/75065>\
**Category:** Visualization\
**Tags:** gadfly, plots, statsplots, algebraofgraphics, vegalite\
**Created:** [January 23, 2022, 1:10pm UTC](https://discourse.julialang.org/t/how-to-make-this-plot-in-julia/75065 "2022-01-23T13:10:07Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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 23, 2022, 5:30pm UTC](https://discourse.julialang.org/t/how-to-make-this-plot-in-julia/75065/4 "2022-01-23T17:30:12Z")

</div>

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

```julia
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()

```

 ![StatsPlots_grouped_line_scatter_plot](https://global.discourse-cdn.com/julialang/original/3X/7/9/79fa6f9097e54979cf251a1e1cf5ede2ec1eee47.png)

---

_[View the full topic](https://discourse.julialang.org/t/how-to-make-this-plot-in-julia/75065)._
