# Julia, how to plot behind previous plot (how to push a plot to the backgrown of another plot)

**URL:** <https://discourse.julialang.org/t/julia-how-to-plot-behind-previous-plot-how-to-push-a-plot-to-the-backgrown-of-another-plot/95093>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [February 23, 2023, 5:04pm UTC](https://discourse.julialang.org/t/julia-how-to-plot-behind-previous-plot-how-to-push-a-plot-to-the-backgrown-of-another-plot/95093 "2023-02-23T17:04:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![franfram](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/franfram/32/47147_2.png) [@franfram](https://discourse.julialang.org/u/franfram)\
**Post date:** [February 23, 2023, 5:04pm UTC](https://discourse.julialang.org/t/julia-how-to-plot-behind-previous-plot-how-to-push-a-plot-to-the-backgrown-of-another-plot/95093/1 "2023-02-23T17:04:34Z")

</div>

Hello,  
I’m plottiong a sin and a cos function with the following code:

```julia
using Makie
x = range(0, 10, length=100)
figure, axis, lineplot = lines(x, sin)
lineplot2 = scatter!(x, cos, color = :red)
figure

```

`lineplot2` appears on top of `lineplot`, that is, the red dots appear on top of the blue line, effectively masking the blue line at some points.  
How do I “push” the red dots so that they appear behind the blue line?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [February 23, 2023, 5:16pm UTC](https://discourse.julialang.org/t/julia-how-to-plot-behind-previous-plot-how-to-push-a-plot-to-the-backgrown-of-another-plot/95093/2 "2023-02-23T17:16:32Z")

</div>

Make sure to speficy the plotting package you are using - there are a number of good options in Julia and they all work differently so an answer can only be helpful if it discussed the one you’re actually using.

From your code snippet I guess you are using Makie, in which case this discussion might be relevant:

> [@Algebra of Graphics z-order? Controlling the plotting order](https://discourse.julialang.org/t/algebra-of-graphics-z-order-controlling-the-plotting-order/66112/3):
>
> There was an “optimization” that scrambled the plotting order, should be addressed by [this PR](https://github.com/JuliaPlots/AlgebraOfGraphics.jl/pull/254) (docs preview [here](http://juliaplots.org/AlgebraOfGraphics.jl/previews/PR254/)). This way the “z-order” should follow the sorting order (smaller values get drawn first and appear first in the legend). This is the same as one would get by doing the plot directly in Makie, so it should be a reasonable default. Could you check out the PR and see if it fixes your usecase? For more nuanced situations (say one wants to order plots and legend differently, or more comp…
