Skip to content

Commit 45caa5f

Browse files
committed
update
1 parent 97d5f0f commit 45caa5f

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ authors = ["Beforerr <[email protected]> and contributors"]
44
version = "1.0.0-DEV"
55

66
[deps]
7-
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
7+
AlgebraOfGraphics = "cbdf2221-f076-402e-a563-3d30da359d67"
8+
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
89

910
[compat]
1011
julia = "1"

src/beforerr.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
module beforerr
22

3-
# Write your package code here.
4-
export add_labels!
3+
using AlgebraOfGraphics, CairoMakie
4+
5+
export add_labels!, pretty_legend!, easy_save
56

67
include("utils/makie.jl")
78

src/utils/makie.jl

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,41 @@
1-
using CairoMakie
2-
31
function add_label!(layout, label; position=TopLeft())
42
Label(layout[1, 1, position], label,
53
font=:bold,
64
padding = (0, 40, 0, 0),
75
halign=:right)
86
end
97

10-
function add_labels!(layouts; labels)
8+
9+
"""
10+
add labels to a grid of layouts
11+
12+
# Notes
13+
- See `tag_facet` in `egg` for reference
14+
"""
15+
function add_labels!(layouts; labels = ('a':'z'), open = "(", close = ")")
1116
for (label, layout) in zip(labels, layouts)
12-
add_label!(layout, label)
17+
tag = open * label * close
18+
add_label!(layout, tag)
1319
end
20+
end
21+
22+
function pretty_legend!(fig, grid)
23+
legend!(fig[0, 1:end], grid, titleposition=:left, orientation=:horizontal)
24+
end
25+
26+
function easy_save(name, fig; dir="figures")
27+
path = "$dir/$name"
28+
mkpath(dir)
29+
30+
save("$path.png", fig, px_per_unit=4)
31+
save("$path.pdf", fig)
32+
33+
# log the path saved
34+
@info "Saved $(abspath(path)).png"
35+
fig
36+
end
37+
38+
function easy_save(name; dir="figures")
39+
fig = current_figure()
40+
easy_save(name, fig, dir=dir)
1441
end

0 commit comments

Comments
 (0)