Skip to content

Commit

Permalink
reduce itererations
Browse files Browse the repository at this point in the history
  • Loading branch information
lazarusA committed Jan 6, 2024
1 parent d2c0294 commit 6c8117d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 46 deletions.
79 changes: 40 additions & 39 deletions examples/aog/penguinsViolins.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,46 @@ function getPenguins()
penguins = dropmissing(DataFrame(PalmerPenguins.load()))
return penguins
end

penguins = getPenguins()
## declare new plot attributes
palette = (color=tuple.(["#FC7808", "#8C00EC", "#107A78"], 0.65),
marker=[:circle, :utriangle, :rect])
cycle = Cycle([:color, :marker], covary=true)

p_len = data(penguins)
p_len *= mapping(:flipper_length_mm => (t -> t / 10),
:bill_length_mm => (t -> t / 10))
p_len *= mapping(color=:species, marker=:species)

bpl = data(penguins)
bpl *= mapping(:species, :bill_length_mm => (t -> t / 10), color = :species)
bpl *= visual(Violin)

bplt = data(penguins)
bplt *= mapping(:species, :flipper_length_mm => (t -> t / 10), color = :species)
bplt *= visual(Violin, orientation = :horizontal)

with_theme(theme_light(), size = (600,400), palette=palette, Scatter=(cycle=cycle,)) do
fig = Figure()
axs = [Axis(fig[2,1], xlabel = "flipper length (cm)", ylabel = "bill length (cm)"),
Axis(fig[1,1]), Axis(fig[2,2])]
dots = draw!(axs[1], p_len)
draw!(axs[2], bplt)
draw!(axs[3], bpl)
## getting the right layout aspect
colsize!(fig.layout, 1, Auto(4.0))
rowsize!(fig.layout, 1, Auto(1/3))
colgap!(fig.layout,3)
rowgap!(fig.layout, 3)
linkxaxes!(axs[1], axs[2])
linkyaxes!(axs[1], axs[3])
hidedecorations!.(axs[2:3], grid=false)
legend!(fig[1,2], dots)
fig
let
penguins = getPenguins()
## declare new plot attributes
palette = (color=tuple.(["#FC7808", "#8C00EC", "#107A78"], 0.65),
marker=[:circle, :utriangle, :rect])
cycle = Cycle([:color, :marker], covary=true)

p_len = data(penguins)
p_len *= mapping(:flipper_length_mm => (t -> t / 10),
:bill_length_mm => (t -> t / 10))
p_len *= mapping(color=:species, marker=:species)

bpl = data(penguins)
bpl *= mapping(:species, :bill_length_mm => (t -> t / 10), color = :species)
bpl *= visual(Violin)

bplt = data(penguins)
bplt *= mapping(:species, :flipper_length_mm => (t -> t / 10), color = :species)
bplt *= visual(Violin, orientation = :horizontal)

fig = with_theme(theme_light(), size = (600,400), palette=palette, Scatter=(cycle=cycle,)) do
fig = Figure()
axs = [Axis(fig[2,1], xlabel = "flipper length (cm)", ylabel = "bill length (cm)"),
Axis(fig[1,1]), Axis(fig[2,2])]
dots = draw!(axs[1], p_len)
draw!(axs[2], bplt)
draw!(axs[3], bpl)
## getting the right layout aspect
colsize!(fig.layout, 1, Auto(4.0))
rowsize!(fig.layout, 1, Auto(1/3))
colgap!(fig.layout,3)
rowgap!(fig.layout, 3)
linkxaxes!(axs[1], axs[2])
linkyaxes!(axs[1], axs[3])
hidedecorations!.(axs[2:3], grid=false)
legend!(fig[1,2], dots)
fig
end

save("penguinsViolins.svg", current_figure()); # hide
end

save("penguinsViolins.svg", current_figure()); # hide

# ![](penguinsViolins.svg)
12 changes: 6 additions & 6 deletions examples/datavis/eigenvals_densities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ end
m(;a=10rand()-5, b=10rand()-5) = [0 0 0 a; -1 -1 1 0; b 0 0 0; -1 -1 -1 -1]

h = HeatMap(range(-3.5,3.5,length=1200), range(-3.5,3.5, length=1200))
getcounts!(h, m; n=1_000_000)
getcounts!(h, m; n=500_000)

with_theme(theme_black()) do
fig = Figure(figure_padding=0,size=(600,600))
Expand All @@ -47,7 +47,7 @@ end
mtri() = Array(Tridiagonal(2rand(19) .-1, 2rand(20) .-1, 2rand(19) .-1))

h = HeatMap(range(-3,3,length=1200÷2),range(-2,2,length=1200÷2))
getcounts!(h, mtri; n=500_000)
getcounts!(h, mtri; n=250_000)

with_theme(theme_black()) do
fig = Figure(figure_padding=0,size=(600,400))
Expand All @@ -62,7 +62,7 @@ end

(; n = 6) = 2rand(Beta(0.01,0.01), n,n) .-1
h = HeatMap(range(-3,3,length=1200),range(-2,2,length=1200))
getcounts!(h, mβ; n=1_000_000)
getcounts!(h, mβ; n=500_000)

with_theme(theme_black()) do
fig = Figure(figure_padding=0,size=(600,400))
Expand All @@ -78,7 +78,7 @@ end

m3(;a=9rand()-5,b=9rand()-5) = [a 1 -1; -1 b 0; 1 -1 -1]
h = HeatMap(range(-4,4,length=1200),range(-2,2,length=1200))
getcounts!(h, m3; n = 1_500_000)
getcounts!(h, m3; n = 500_000)

with_theme(theme_dark()) do
fig = Figure(figure_padding=0,size=(600,400))
Expand All @@ -96,7 +96,7 @@ mtrin(; n =30) = Array(Tridiagonal(rand([-1.0,1.0],n-1), zeros(n), rand([-1.0,1.

h = HeatMap(range(-2,2,length=1200),range(-2,2,length=1200))

getcounts!(h, mtrin; n = 100_000)
getcounts!(h, mtrin; n = 50_000)

with_theme(theme_dark()) do
fig = Figure(figure_padding=0,size=(600,600))
Expand All @@ -112,7 +112,7 @@ end

mrand(; f=1000,n=8) = rand([-1.0, -1/f, 0, 1/f, 1.0],n,n)
h = HeatMap(range(-2,2,length=800), range(-2,2,length=800))
getcounts!(h, mrand; n = 500_000)
getcounts!(h, mrand; n = 250_000)

with_theme(theme_dark()) do
fig = Figure(figure_padding=0,size=(600,600))
Expand Down
2 changes: 1 addition & 1 deletion examples/datavis/eigenvals_evolution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function m12(n=10)
return a, b
end

n = 150
n = 100
a, b = m12(n)
xs, ys = xy(a,b)
colors = repeat(1:n,inner=500)
Expand Down

0 comments on commit 6c8117d

Please sign in to comment.