# \[solved\] Plotting 2 plots on same figure with dual axis

**URL:** <https://discourse.julialang.org/t/solved-plotting-2-plots-on-same-figure-with-dual-axis/124623>\
**Category:** Visualization\
**Tags:** question, plotting, makie, glmakie\
**Created:** [January 10, 2025, 5:25am UTC](https://discourse.julialang.org/t/solved-plotting-2-plots-on-same-figure-with-dual-axis/124623 "2025-01-10T05:25:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hisacro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hisacro/32/202631_2.png) [@hisacro](https://discourse.julialang.org/u/hisacro)\
**Post date:** [January 10, 2025, 5:25am UTC](https://discourse.julialang.org/t/solved-plotting-2-plots-on-same-figure-with-dual-axis/124623/1 "2025-01-10T05:25:29Z")

</div>

I wanted to plots 2 data on the same figure with their respective legends one on left, bottom while for the other on top and right. For example,

```julia
using Plots,
plot([.4,.3],[.8,.3])
plot!([5,3],[4,8])

```

this is the output,

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/b/bb05561e7c15b73e52330690a11b67600b28b29f.png)  
instead I want something like,  
 ![sample](https://global.discourse-cdn.com/julialang/original/3X/e/f/ef6e39672ccb2bfe70fbf613062c8adfc6710f65.png)

---

<div class="post-metadata">

**Author:** ![hisacro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hisacro/32/202631_2.png) [@hisacro](https://discourse.julialang.org/u/hisacro)\
**Post date:** [January 10, 2025, 6:55am UTC](https://discourse.julialang.org/t/solved-plotting-2-plots-on-same-figure-with-dual-axis/124623/2 "2025-01-10T06:55:59Z")

</div>

> **[Axis | Makie](https://docs.makie.org/stable/reference/blocks/axis#Creating-a-twin-axis)**
>
> Create impressive data visualizations with Makie, the plotting ecosystem for the Julia language. Build aesthetic plots with beautiful customizable themes, control every last detail of publication quality vector graphics, assemble complex layouts and...

It’s called twin axis.

```julia
f = Figure();

# Initializing axis
ax1 = Axis(f[1, 1], xticklabelcolor= :blue, yticklabelcolor = :blue)
ax2 = Axis(f[1, 1], xticklabelcolor = :red, yticklabelcolor= :red, xaxisposition = :top, yaxisposition = :right)

# plot for each axis
lines!(ax1, [4,3],[5,3], color = :blue)
lines!(ax2, [.5,.3],[.25,.9], color = :red)

f

```

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