# Makie: Coordinates of objects in the "scene" coordinates?

**URL:** <https://discourse.julialang.org/t/makie-coordinates-of-objects-in-the-scene-coordinates/105907>\
**Category:** Visualization\
**Tags:** question, makie\
**Created:** [November 7, 2023, 4:36pm UTC](https://discourse.julialang.org/t/makie-coordinates-of-objects-in-the-scene-coordinates/105907 "2023-11-07T16:36:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Post date:** [November 7, 2023, 4:36pm UTC](https://discourse.julialang.org/t/makie-coordinates-of-objects-in-the-scene-coordinates/105907/1 "2023-11-07T16:36:50Z")

</div>

This is a continuation of the thread that I link at the end of this message. There I went off topic and so I thought it’s wiser to start a new thread instead of posting further questions there.

My question is, how do you find out the locations of “axis” objects in terms of the “scene coordinates”.

In the following toy example, I plot two graphs (“Axes”) side by side and later add a horizontal line to the “scene” that marks the location of the common y origin:

```julia
using CairoMakie
fig = Figure()
ax1 = Axis(fig[1,1], limits=(nothing,(-0.3, 1.5)) )
ax2 = Axis(fig[1,2], limits=(nothing,(-0.3, 1.5)) )
xs = 0:(pi/16):(2pi)
lines!(ax1, xs, map(sin, xs))
lines!(ax2, xs, map(cos, xs))
lines!(fig.scene, [0.06, 0.98], [0.22177,0.22177]; space = :relative,
       color = RGBAf(0.5,0.5,0.5,0.5) )
save("tmp.png", fig)

```

 ![tmp](https://global.discourse-cdn.com/julialang/original/3X/1/0/10aed8d37bfcb9d0f4fd2cc133fab56f96e00786.png)

In this example, I found out the location of the y axis just by trial and error, but you of course want to systematically calculate the position without trial and error.

In the past, I did this kind of trial and error many times on other plotting tools. What’s depressing about trial and error is that you have to redo the trial and error if/when you change something about the main plots. . . .

The above is just an example. There are potentially a lot of uses. For example, you might want to plot a piece of text at a certain “scene” position relative to some elements of multiple “Axes”.

> [@Makie: Put text at arbitrary position outside the frame](https://discourse.julialang.org/t/makie-put-text-at-arbitrary-position-outside-the-frame/105322/1):
>
> From a past thread (see below), I learned how to put arbitrary text outside the frame. But, am I right that it’s impossible or extremely tedious to put text at an arbitrary position? I’ve plotted the following figure, which is okay, but there is too much space between the y axes. One solution is to move the y-axis labels above the upper ends of the corresponding y axes. I tried text!(ax1, . . . ) but the text appears only within the frame. Is it possible to switch off the clipping behavior? T…

---

<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 7, 2023, 6:50pm UTC](https://discourse.julialang.org/t/makie-coordinates-of-objects-in-the-scene-coordinates/105907/2 "2023-11-07T18:50:15Z")

</div>

An `Axis` shows its plot content in a separate `Scene`, which is in `ax.scene`. This `Scene` has a rectangular viewport area, which is in `ax.scene.px_area`. This rectangle gives you the location of the `Axis` in the `Figure` at any given time. It’s an observable, so you can `lift` other stuff off it.

---

<div class="post-metadata">

**Author:** ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Post date:** [November 8, 2023, 7:42am UTC](https://discourse.julialang.org/t/makie-coordinates-of-objects-in-the-scene-coordinates/105907/3 "2023-11-08T07:42:43Z")

</div>

Thanks! I’ll explore that and report back in due course.
