In Makie.jl, how can I draw a box around a text? More specifically, I’d like to draw the bounding box of a given text that I’ve plotted using the
In fact, it is even better if I could use the existing
Textbox, which looks gorgeous, and already has all the customization I need regarding line and box colors. But so far
Textbox is a layoutable, while I want it to be plottable at arbitrary locations on an axis.
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
fig, ax, p = text("Test", position = Point2f(2))
scene = campixel(ax.scene);
bb = Rect2f(boundingbox(
Makie.to_ndim(Point3f, Makie.project(ax.scene, p.plots.position), 0),
mesh!(scene, bb, color = :yellow, shading = false)
translate!(scene, 0, 0, -1)
boundingbox(p) seems to fall back on some default method that isn’t useful.
boundingbox(p.plots) 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.