# \[ANN\] AlgebraOfGraphics v0.7

**URL:** https://discourse.julialang.org/t/ann-algebraofgraphics-v0-7/117124
**Category:** Package Announcements
**Tags:** plotting, makie, algebraofgraphics
**Created:** [July 17, 2024, 6:13am UTC](https://discourse.julialang.org/t/ann-algebraofgraphics-v0-7/117124 "2024-07-17T06:13:02Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [July 17, 2024, 6:13am UTC](https://discourse.julialang.org/t/ann-algebraofgraphics-v0-7/117124/1 "2024-07-17T06:13:02Z")

</div>

Hello everybody,

I’m excited to present version 0.7 of [AlgebraOfGraphics.jl](https://github.com/MakieOrg/AlgebraOfGraphics.jl). This is work that I’ve been doing during the last two or three months, as we at [PumasAI](https://pumas.ai/) like to use the package but it had been in need of some refactoring for a while. This refactor is breaking in some aspects but it leaves the basic ideas and framework of the package untouched, so a transition is hopefully straightforward. It mostly adds some semantics on top that make it more flexible and powerful.

For more information about the reasoning behind all of this, please refer to [PR 505](https://github.com/MakieOrg/AlgebraOfGraphics.jl/pull/505). For a brief overview of the breaking changes and new features, check [https://aog.makie.org/stable/release\_notes/](https://aog.makie.org/stable/release_notes/). Note that because there are so many of them, not all of Makie’s plotting functions or all plot attributes have been enabled for the new system, yet, if you need a specific one please open an issue or file a PR.

Here are some example plots showcasing the new capabilities because we all like images to look at 🙂 Hope you enjoy the new release!

### Horizontal/vertical bar plots, rainclouds, violins, errorbars, etc.

```julia
df = (; x = 1:10, y = string.('A':'J'))
data(df) * mapping(:y, :x) * visual(BarPlot, direction = :x) |> draw

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/1/01d873627854913086784e22e240f91a5b43ec91.png)

```julia
group = repeat(["A", "B", "C", "D"], inner = 250)
measurements = randn(1000) .* repeat(1:4, inner = 250)
df = (; group, measurements)
data(df) * mapping(:group, :measurements, color = :group) *
    visual(RainClouds, orientation = :horizontal) |> draw

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/7/572652f8d3accd61fe1b48629e8c189a255bd93e.png)

### `mapping` with raw vectors, not using `data()`:

```julia
mapping(1:90, cumsum(randn(90)), color = repeat(["A", "B", "C"], inner = 30)) *
    visual(Scatter) |> draw

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/e/9ed14fdf95ee221aa4033716b2d6395ec151327b.png)

### Quickly use data from outside a tabular dataset with `direct`

```julia
df = (; x = 1:20, group = repeat(["A", "B"], inner = 10))
y = sin.(range(0, 2pi, length = 20))
data(df) * mapping(:x, direct(y), color = :group) |> draw

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/7/a/7ae38945d03038bc74ca32852fc626ea87b37255.png)

### Markersize mapping with legend

```julia
t = 0:0.1:10
mapping(cos.(t) .* t, sin.(t) .* t, markersize = t) * visual(Scatter) |> draw

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/8/283f75f5d348f40878cc20cead76e7ff410072e0.png)

### Separate scales of same aesthetic type

```julia
spec1 = mapping(
    1:300,
    cumsum(randn(300)) .+ repeat([0, 10, 20], inner = 100),
    color = repeat(["A", "B", "C"], inner = 100)
) * visual(Scatter)

spec2 = mapping([30, 80, 178, 260], color = ["X", "Y", "X", "Y"] => scale(:secondary)) *
    visual(VLines, linestyle = :dash, linewidth = 2)
    
draw(spec1 + spec2, scales(secondary = (; palette = [:tomato, :gray60])))

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/6/06b3b58a848f61615d26caf3b49a2f4b464101e9.png)

### Category additions and modified placement

```julia
df = (; x = ["A", "C", "D", "missing"], y = [3, 2, 6, 3])
data(df) * mapping(:x, :y) * visual(BarPlot) |>
    draw(
        scales(
            X = (;
                categories = ["A", "B", "C", "D", "missing"],
                palette = [1, 2, 3, 4, 6]
        )
    )
)

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/d/bdc5b70069cb92081117ea6f4876eb0f63ebaf41.png)

### Map `strokecolor` and other color attributes not named `color`

```julia
mapping(randn(50), randn(50), strokecolor = rand(["A", "B"], 50)) * 
    visual(Scatter, color = :gray90, strokewidth = 3, markersize = 20) |> draw

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/3/2322cedf534c49dc95166e3625cfbe356098ecf0.png)

### Reorder legends

```julia-auto
df = (;
    x = 1:12,
    y = 1:12,
    z = 1:12,
    group1 = repeat(["A", "B", "C"], inner = 4),
    group2 = repeat(["X", "Y"], 6),
)

spec = data(df) *
    mapping(:x, :y, markersize = :z, color = :group1, marker = :group2) *
    visual(Scatter)

draw(spec; legend = (; order = [:MarkerSize, :Color, :Marker]))

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/a/5a146bef1dd1fb1d0c2993075e9788dcad7361fa.png)

### Merge legends

```julia
df = (;
    x = 1:12,
    y = 1:12,
    z = 1:12,
    group1 = repeat(["A", "B", "C"], inner = 4),
    group2 = repeat(["X", "Y"], 6),
)

spec = data(df) *
    mapping(:x, :y, markersize = :z, color = :group1, marker = :group2) *
    visual(Scatter)

draw(spec; legend = (; order = [[:MarkerSize, :Color, :Marker] => "Merged"]))

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/6/567619532970857c9efef09b868ca5d6adda01cc.png)

---

<div class="post-metadata">

### Author: ![TheLateKronos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thelatekronos/32/12824_2.png) [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)
#### Post date: [July 21, 2024, 5:45am UTC](https://discourse.julialang.org/t/ann-algebraofgraphics-v0-7/117124/2 "2024-07-21T05:45:26Z")

</div>

This is awesome. Thanks for the work ❤
