# How to draw 2D text on top of a 3D figure with Makie

**URL:** <https://discourse.julialang.org/t/how-to-draw-2d-text-on-top-of-a-3d-figure-with-makie/59983>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [April 25, 2021, 12:13pm UTC](https://discourse.julialang.org/t/how-to-draw-2d-text-on-top-of-a-3d-figure-with-makie/59983 "2021-04-25T12:13:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [April 25, 2021, 12:13pm UTC](https://discourse.julialang.org/t/how-to-draw-2d-text-on-top-of-a-3d-figure-with-makie/59983/1 "2021-04-25T12:13:55Z")

</div>

I have the following code:

```julia
using GeometryBasics, GLMakie

const SCALE = 1.2
const SEGMENTS = 7 # number of tether segments

function create_coordinate_system(scene, points = 10, length = 10)
    # create y-axis in green
    points -= 3
    mesh!(scene, Cylinder(Point3f0(0, -(points+1) * SCALE, 0), Point3f0(0, (points+1) * SCALE , 0), Float32(0.05 * SCALE)), color=:green)
    for i in range(0, length=10)
        start = Point3f0(0, (points+1 + 0.07 * (i-0.5)) * SCALE, 0)
        stop = Point3f0(0, (points+1 + 0.07 * (i+0.5)) * SCALE, 0)
        mesh!(scene, Cylinder(start, stop, Float32(0.018 * (10 - i) * SCALE)), color=:green)
    end
end

function main()
    scene, layout = layoutscene(resolution = (840, 900), backgroundcolor = RGBf0(0.7, 0.8, 1))
    scene3D = LScene(scene, scenekw = (show_axis=false, limits = Rect(-7,-10.0,0, 11,10,11), resolution = (800, 800)), raw=false)
    create_coordinate_system(scene3D)

    cam = cameracontrols(scene3D.scene)
    cam.lookat[] = [0,0,5]
    cam.eyeposition[] = [-15,-15,5]
    update_cam!(scene3D.scene)

    layout[1, 1] = scene3D
    layout[2, 1] = buttongrid = GridLayout(tellwidth = false)
    buttongrid[1, 1:1] = [Button(scene, label = "RESET")]

    text!(scene3D, "12345", position = Point2f0(0, 0), textsize = 30, align = (:left, :bottom), show_axis = false, space = :screen)
    text!(scene, "54321", position = Point2f0(0, 200), textsize = 30, align = (:left, :bottom), show_axis = false, space = :screen)

    display(scene)
  
    return nothing
end

```

It creates the attached graph. I tried two ways to display text, first to plot it on scene3D and in the second line to plot it on scene. If I plot it on scene3D it gets distorted, and if I plot it on scene the 3D scene hides the text that is behind it.

How can I draw undistorted text that is not hidden?

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

---

<div class="post-metadata">

**Author:** ![ffreyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffreyer/32/21569_2.png) [@ffreyer](https://discourse.julialang.org/u/ffreyer)\
**Post date:** [April 25, 2021, 3:19pm UTC](https://discourse.julialang.org/t/how-to-draw-2d-text-on-top-of-a-3d-figure-with-makie/59983/2 "2021-04-25T15:19:17Z")

</div>

That should work. Are you up to date on GLMakie and AbstractPlotting?

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [April 25, 2021, 3:50pm UTC](https://discourse.julialang.org/t/how-to-draw-2d-text-on-top-of-a-3d-figure-with-makie/59983/3 "2021-04-25T15:50:35Z")

</div>

```julia
(KiteViewer) pkg> st
      Status `~/repos/KiteViewer/Project.toml`
  [537997a7] AbstractPlotting v0.15.27
  [69666777] Arrow v1.4.1
  [5789e2e9] FileIO v1.7.0
  [e9467ef8] GLMakie v0.1.30
  [5c1252a2] GeometryBasics v0.3.12
  [ee78f7c6] Makie v0.12.0
  [7269a6da] MeshIO v0.4.6
  [9b87118b] PackageCompiler v1.2.5
  [731186ca] RecursiveArrayTools v2.11.3
  [295af30f] Revise v3.1.15
  [6038ab10] Rotations v1.0.2
  [90137ffa] StaticArrays v1.1.1
  [09ab397b] StructArrays v0.5.1
  [9ff05d80] TickTock v1.1.0
  [ddb6d928] YAML v0.4.6

```

It was working about 4 months ago. I think it also works on Windows. But not any longer on Linux.

To be clear: I want to see “54321” instead of “54”.

---

<div class="post-metadata">

**Author:** ![ffreyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffreyer/32/21569_2.png) [@ffreyer](https://discourse.julialang.org/u/ffreyer)\
**Post date:** [April 25, 2021, 4:13pm UTC](https://discourse.julialang.org/t/how-to-draw-2d-text-on-top-of-a-3d-figure-with-makie/59983/4 "2021-04-25T16:13:12Z")

</div>

screen space text is AbstractPlotting v0.16+ and GLMakie v0.2+

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [April 25, 2021, 4:43pm UTC](https://discourse.julialang.org/t/how-to-draw-2d-text-on-top-of-a-3d-figure-with-makie/59983/5 "2021-04-25T16:43:43Z")

</div>

Thank you! I had to remove Makie from my project to be able to upgrade GLMakie and AbstractPlotting, but now it seams to work fine! 😃
