# Improve a plot done with AoG and Makie

**URL:** <https://discourse.julialang.org/t/improve-a-plot-done-with-aog-and-makie/88133>\
**Category:** Visualization\
**Created:** [October 2, 2022, 8:25pm UTC](https://discourse.julialang.org/t/improve-a-plot-done-with-aog-and-makie/88133 "2022-10-02T20:25:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinmestre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martinmestre/32/215857_2.png) [@martinmestre](https://discourse.julialang.org/u/martinmestre)\
**Post date:** [October 2, 2022, 8:25pm UTC](https://discourse.julialang.org/t/improve-a-plot-done-with-aog-and-makie/88133/1 "2022-10-02T20:25:24Z")

</div>

Hello,  
I have used the following function to make the plot below:

```julia
"""Plot splus stars in the streams footprints"""
function plot_splus_streams(df::DataFrame, file::String)
    df.anotta = df.track
    unicos = unique(df.track)
    println(unicos)
    lu = length(unicos)
    ra = zeros(lu)
    dec = zeros(lu)
    for i in 1:lu
        bool_st = (df.track .== unicos[i])
        ra[i] = df.RA[bool_st][1]
        dec[i] = df.DEC[bool_st][1]
        df.anotta[bool_st] = repeat(["$i = $(unicos[i])"],sum(bool_st))
    end
    df_text = DataFrame(ra=ra, dec=dec, id=string.(eachindex(unicos)))

    size_inches = (8*3, 6*3)
    size_pt = 72 .* size_inches
    fig = Figure(resolution = size_pt, fontsize = 24)
    plt = data(df)*visual(markersize=2)*mapping(:RA=>L"RA [$°$]", :DEC=>L"Dec [$°$]", color=:anotta)
    plt_text = data(df_text)*mapping(:ra, :dec, text=:id=>verbatim)*visual(Makie.Text)
    f=draw!(fig[1,1], plt+plt_text, axis=(; xgridvisible=false, ygridvisible=false))
    legend!(fig[2,1], f; tellwidth=true, patchsize=(8*3,3*3), nbanks=5, alignmode=Outside())
    save(file, fig, pt_per_unit=5)
end

```

I would like to modify two things: a) having the legend closer to the figure and b) the numbers in order. I think that using `fig[2,1]` in the legend line is not right but if I use `fig[1,1]` I obtain the legend inside the figure, which is something I do not want.

By the way, how is the logic of ` fig[i,j]`? When are they created and which is the size of `fig`?  
Thank you very much.

 ![splus_streams](https://global.discourse-cdn.com/julialang/original/3X/c/a/cac9b8685671c807bbabf7a7cbce8ddc2da1f885.png)
