# How to move markers in a scatter plot above the x-axis in CairoMakie?

**URL:** <https://discourse.julialang.org/t/how-to-move-markers-in-a-scatter-plot-above-the-x-axis-in-cairomakie/106345>\
**Category:** General Usage\
**Tags:** plotting, makie\
**Created:** [November 17, 2023, 12:58am UTC](https://discourse.julialang.org/t/how-to-move-markers-in-a-scatter-plot-above-the-x-axis-in-cairomakie/106345 "2023-11-17T00:58:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![curious](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/curious/32/7629_2.png) [@curious](https://discourse.julialang.org/u/curious)\
**Post date:** [November 17, 2023, 12:58am UTC](https://discourse.julialang.org/t/how-to-move-markers-in-a-scatter-plot-above-the-x-axis-in-cairomakie/106345/1 "2023-11-17T00:58:51Z")

</div>

Hi,

I am trying to create a dot plot with CairoMakie  
using the `scatter` function. I want the dots to appear above the x-axis spine and decorations. Currently they are being partially hidden as the spine and decorations are being drawn over the markers from the scatter plot. Can this be done? If yes, can someone please suggest a way of doing this. I tried finding something like z-index, z-order from CSS, but could not find it in the docs. Below is my code and the pdf file showing the plot.  
Thank you.

```julia
function draw_dot_plot(df)
    size_in = (6,3)
    size_pt = 72 .* size_in
    fig = Cm.Figure(resolution = size_pt, fontsize = 12)
    ax = Cm.Axis(fig[1,1],
                 bottomspinevisible=true,
                 topspinevisible=false,
                 rightspinevisible=false,
                 leftspinevisible=false,
                 xticks=0:0.1:1,
                 xgridvisible=false)
    Cm.limits!(-0.02, 1.05, 0.05, 1)
    Cm.hideydecorations!(ax)
    xvec, yvec = create_dotplot_data(df)
    Cm.scatter!(ax, xvec, yvec, 
                marker = :circle)
    Cm.save("./temp/line.pdf", fig, pt_per_unit = 1)
end

```

_Plot_  
 ![line](https://global.discourse-cdn.com/julialang/original/3X/4/d/4d82bdca838f9180d4ad82707a80b4a58077c94d.png)

---

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [November 17, 2023, 1:21am UTC](https://discourse.julialang.org/t/how-to-move-markers-in-a-scatter-plot-above-the-x-axis-in-cairomakie/106345/2 "2023-11-17T01:21:12Z")

</div>

Typically it is unusual to have markers extruding out of axes. You can shift the y-axis a little bit so that markers can fully appears inside the plot.

---

<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:** [November 17, 2023, 8:25am UTC](https://discourse.julialang.org/t/how-to-move-markers-in-a-scatter-plot-above-the-x-axis-in-cairomakie/106345/3 "2023-11-17T08:25:43Z")

</div>

CairoMakie (or any Makie backend) currently doesn’t have the option to disable the rectangular clipping for a `Scene`. What you can do instead is plot into a larger scene, that would be either `ax.blockscene` or `fig.scene`, both of which cover the whole figure and use screen space coordinates. That makes placing dots in data coordinates a bit more complicated because you have to convert the coordinates.

```julia
f, ax, l = lines(randn(10))
dot_x_dataspace = Observable(3:2:9)
dot_pos_screenspace = lift(dot_x_dataspace, ax.finallimits, ax.scene.px_area) do xs, lims, pxa
    points = map(xs) do x
        pxa.origin + Point2f(pxa.widths[1] * (x - lims.origin[1]) / lims.widths[1], 0)
    end
end
sc = scatter!(ax.blockscene, dot_pos_screenspace, markersize = 20)
translate!(sc, 0, 0, 100)
f

```

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

---

<div class="post-metadata">

**Author:** ![curious](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/curious/32/7629_2.png) [@curious](https://discourse.julialang.org/u/curious)\
**Post date:** [November 17, 2023, 12:53pm UTC](https://discourse.julialang.org/t/how-to-move-markers-in-a-scatter-plot-above-the-x-axis-in-cairomakie/106345/4 "2023-11-17T12:53:47Z")

</div>

Thank you @liuyxpp. I will look at the API for how to shift the y-axis.  
Thank you also @jules. I will need to study your solution to understand what it is doing.
