# 2D plot flush with 3D axis?

**URL:** <https://discourse.julialang.org/t/2d-plot-flush-with-3d-axis/62289>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [June 2, 2021, 4:37pm UTC](https://discourse.julialang.org/t/2d-plot-flush-with-3d-axis/62289 "2021-06-02T16:37:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlchan/32/10958_2.png) [@jlchan](https://discourse.julialang.org/u/jlchan)\
**Post date:** [June 2, 2021, 4:37pm UTC](https://discourse.julialang.org/t/2d-plot-flush-with-3d-axis/62289/1 "2021-06-02T16:37:33Z")

</div>

I’m trying to plot a 2D graph underneath a 3D plot. The following is my hacky approach,

```julia
using GLMakie

fig = Figure()
menu = Menu(fig, options = [1,2])
fig[1, 1] = vgrid!(
    Label(fig, "Index a", width = nothing),menu;
    tellheight = false, width = 200)
ax = Axis3(fig[1, 2])

menu.selection[] = 1

function my_function(a,x)
    data = [sin.(pi*x), 5 .+ cos.(pi*x)]
    return data[a]
end
xplot = LinRange(-1,1,100)
yplot = cos.(pi*xplot)
zplot = @lift my_function($(menu.selection),xplot) 
plt = lines!(ax, xplot, yplot, zplot)

# I'd like this line to be flush against the bottom boundary
lines!(ax, -1:1, -1:1, Makie.@lift(ones(3)*minimum($zplot)))

on(menu.selection) do s
    Makie.autolimits!(ax)
end

fig

```

but the line isn’t flush with the bottom boundary.

 ![Screen Shot 2021-06-02 at 11.36.05 AM](https://global.discourse-cdn.com/julialang/original/3X/c/5/c5a557615194ded0beb1b35bc824f8e98b655e7e.jpeg)

Is there a way to plot a line flush against the bottom of an Axis3, and to have that update with `autolimits!`?

---

<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 2, 2021, 5:07pm UTC](https://discourse.julialang.org/t/2d-plot-flush-with-3d-axis/62289/2 "2021-06-02T17:07:14Z")

</div>

Yeah you just have to change the autolimit margins so there’s no additional space at the bottom. Without looking it up, I guess ax3.zautolimitmargin = (0, 0.05) could work.

---

<div class="post-metadata">

**Author:** ![jlchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlchan/32/10958_2.png) [@jlchan](https://discourse.julialang.org/u/jlchan)\
**Post date:** [June 2, 2021, 5:14pm UTC](https://discourse.julialang.org/t/2d-plot-flush-with-3d-axis/62289/3 "2021-06-02T17:14:06Z")

</div>

Works like a charm. Thanks!

---

<div class="post-metadata">

**Author:** ![jlchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlchan/32/10958_2.png) [@jlchan](https://discourse.julialang.org/u/jlchan)\
**Post date:** [June 2, 2021, 5:33pm UTC](https://discourse.julialang.org/t/2d-plot-flush-with-3d-axis/62289/4 "2021-06-02T17:33:39Z")

</div>

Shoot, I spoke to soon - it works for the first plot, but doesn’t refresh after menu selection.

---

<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 5, 2021, 6:29am UTC](https://discourse.julialang.org/t/2d-plot-flush-with-3d-axis/62289/5 "2021-06-05T06:29:45Z")

</div>

If it doesn’t refresh, maybe your observable order is wrong and the axis updates first, then the data?

---

<div class="post-metadata">

**Author:** ![jlchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlchan/32/10958_2.png) [@jlchan](https://discourse.julialang.org/u/jlchan)\
**Post date:** [June 5, 2021, 8:25pm UTC](https://discourse.julialang.org/t/2d-plot-flush-with-3d-axis/62289/6 "2021-06-05T20:25:51Z")

</div>

Sorry, my description may have been misleading.

The line plot starts out flush with the bottom upon running the script, but after a menu selection, the line is no longer flush with the bottom. I set `ax.zautolimitmargin = (0.0,.05)` and it stays the same after menu selection, but the plot no longer honors these limits.

---

<div class="post-metadata">

**Author:** ![jlchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlchan/32/10958_2.png) [@jlchan](https://discourse.julialang.org/u/jlchan)\
**Post date:** [June 6, 2021, 3:43am UTC](https://discourse.julialang.org/t/2d-plot-flush-with-3d-axis/62289/7 "2021-06-06T03:43:07Z")

</div>

Went with another approach for now - we switched to LScene() for zoom interactivity and turned off the axis (so there’s no need to flush the bottom plot with anything anymore).

I don’t know how to make `autolimits!` to work with LScene(), but with interactivity we can at least just move the plot around manually after `menu.selection` picks out a solution.
