# How to draw a textbox around a text in Makie.jl?

**URL:** <https://discourse.julialang.org/t/how-to-draw-a-textbox-around-a-text-in-makie-jl/75672>\
**Category:** Visualization\
**Tags:** question, makie\
**Created:** [February 2, 2022, 4:23pm UTC](https://discourse.julialang.org/t/how-to-draw-a-textbox-around-a-text-in-makie-jl/75672 "2022-02-02T16:23:51Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [February 2, 2022, 11:57pm UTC](https://discourse.julialang.org/t/how-to-draw-a-textbox-around-a-text-in-makie-jl/75672/2 "2022-02-02T23:57:01Z")

</div>

The two step projection makes this a bit more complicated. With the text position in data space and the textsize in pixel units you’d need

```julia
fig, ax, p = text("Test", position = Point2f(2))
scene = campixel(ax.scene);
bb = Rect2f(boundingbox(
    p.plots[1][1][], 
    Makie.to_ndim(Point3f, Makie.project(ax.scene, p.plots[1].position[]), 0), 
    Makie.to_rotation(p.plots[1].rotation[])
))
mesh!(scene, bb, color = :yellow, shading = false)
lines!(scene, bb)
translate!(scene, 0, 0, -1)
fig

```

`boundingbox(p)` seems to fall back on some default method that isn’t useful. `boundingbox(p.plots[1])` does use the right method but assumes the text position and textsize to be in the same space. So you need to project position into pixel space first and use the boundingbox above. The result is in pixelspace so you need to plot in on a scene with a pixel camera.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-draw-a-textbox-around-a-text-in-makie-jl/75672)._
