-
-
Notifications
You must be signed in to change notification settings - Fork 361
Description
There appear to be some issues with text bounding boxes when used within an axis. Especially when the axis is scaled by a transform.
Expected behavior
using CairoMakie, StableRNGs
x = cumsum(randn(StableRNG(1), 100).^2)
f = lines(x, axis=(yscale=log10,))
lbl = text!(f.axis, text="Direct Labels are Great!", 50, 50, align=(:right,:bottom))
bb = boundingbox(lbl)
wireframe!(f.axis, bb, color=:red, space=:data)
f
shows a bounding box around the text string.
Changing wireframe!(f.axis, bb, color=:red, space=:data) to wireframe!(f.axis.scene, bb, color=:red, space=:pixel) shows no bounding box. Adding campixel(f.axis.scene) does not work either. Plotting text! into f.axis.scene also made no difference.
Where we do see somewhat expected behavior
using CairoMakie, StableRNGs
x = cumsum(randn(StableRNG(1), 100).^2)
f = lines(x) # CHANGE, no log10 scale...
scene = campixel(f.axis.scene) # CHANGE
lbl = text!(scene, 200, 200, text="Direct Labels are Great!", align=(:right,:bottom),space=:pixel)
bb = boundingbox(lbl)
wireframe!(scene, bb, color=:red, space=:pixel)
f
This does work, but requires pixel coordinates for the text rather than data coordinates.
This also fails with specifying a logscale y axis...
using CairoMakie, StableRNGs
x = cumsum(randn(StableRNG(1), 100).^2)
f = lines(x, axis=(yscale=log10,)) # CHANGE, log10 scale...
scene = campixel(f.axis.scene) # CHANGE
lbl = text!(scene, 200, 200, text="Direct Labels are Great!", align=(:right,:bottom),space=:pixel)
bb = boundingbox(lbl)
wireframe!(scene, bb, color=:red, space=:pixel)
f
This was verified on the most recent versions I could update to of CairoMakie (CairoMakie v0.9.2) and Makie (Makie v0.18.2)
See origin of this discussion here:
https://discourse.julialang.org/t/automatic-direct-labels-for-makie-with-voronoi-tessellation/90247/4


