# Plot combination and rotation using CairoMakie and AlgebraOfGraphics

**URL:** https://discourse.julialang.org/t/plot-combination-and-rotation-using-cairomakie-and-algebraofgraphics/116332
**Category:** Visualization
**Tags:** question, plotting
**Created:** [June 28, 2024, 6:18am UTC](https://discourse.julialang.org/t/plot-combination-and-rotation-using-cairomakie-and-algebraofgraphics/116332 "2024-06-28T06:18:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Bonjour-Lemonde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bonjour-lemonde/32/24199_2.png) [@Bonjour-Lemonde](https://discourse.julialang.org/u/Bonjour-Lemonde)
#### Post date: [June 28, 2024, 6:18am UTC](https://discourse.julialang.org/t/plot-combination-and-rotation-using-cairomakie-and-algebraofgraphics/116332/1 "2024-06-28T06:18:40Z")

</div>

Hi all,  
I want to know how to achieve plotting as shown below:

 ![the goal](https://global.discourse-cdn.com/julialang/original/3X/d/b/db2002577a3591e887a3bb3d19c7531d1df393dd.jpeg)  
currently, I could only achieved plotting as shown below using the following code:  
 ![current](https://global.discourse-cdn.com/julialang/original/3X/a/8/a8dc647c9751a764e3e088b5af7f41fece4586ab.jpeg)

```julia
using AlgebraOfGraphics
using Distributions
using DataFrames
using CairoMakie

dx = Normal(20,1)
dy = Normal(25,1)
x = rand(dx, 50)
y = rand(dy, 50)

dn2 = DataFrame(x = x, y = y)

p1 = data(dn2) * mapping([:x, :y] .=> "variables") *
    AlgebraOfGraphics.density() * 
    mapping(color = dims(1) => renamer(["x", "y"]))
draw(p1,axis = (width = 200, height = 200))

```

You can see that I need to first rotate the axis and then combine multiple figures, and I want to know if it is currently available using CairoMakie and AlgebraOfGraphics. Thanks in advance for help!

---

<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: [June 28, 2024, 9:06am UTC](https://discourse.julialang.org/t/plot-combination-and-rotation-using-cairomakie-and-algebraofgraphics/116332/2 "2024-06-28T09:06:19Z")

</div>

After this upcoming refactor [Explicit aesthetics / scales by jkrumbiegel · Pull Request #505 · MakieOrg/AlgebraOfGraphics.jl · GitHub](https://github.com/MakieOrg/AlgebraOfGraphics.jl/pull/505) this code will work, currently the flipped histogram is not really supported with correct axis labels:

```julia
let 
    group = rand(1:8, 1000)
    x = randn.() .+ group
    df = (; x, group)
    spec = data(df) *
        mapping(:x, col = :group => nonnumeric) *
        AoG.histogram(bins = 80) *
        visual(direction = :x)
    with_theme(theme_minimal()) do
        draw(spec)
    end
end

```

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

---

<div class="post-metadata">

### Author: ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)
#### Post date: [June 28, 2024, 9:14am UTC](https://discourse.julialang.org/t/plot-combination-and-rotation-using-cairomakie-and-algebraofgraphics/116332/3 "2024-06-28T09:14:17Z")

</div>

[hist | Makie](https://docs.makie.org/v0.21/reference/plots/hist#Moving-histograms)

But I have a [question](https://discourse.julialang.org/t/questions-on-hist-makie/116347) on it.
