MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.38k stars 302 forks source link

Allow `padding` keyword for `Textbox` #3822

Open Datseris opened 4 months ago

Datseris commented 4 months ago

Feature description

Textbox brings a much needed feature to Makie: adding a text with surrounding box in the figure. It has all options necessary to style the textbox as you wish. Without Textbox, actually making text with a surrounding box can be very tedious and complex, and thus very hard to memorize, e.g., https://discourse.julialang.org/t/fill-a-bounding-box-behind-text-in-makie/101502/3.

The only thing I am misssing from Textbox is an additional padding argument, that controls the pad of the box borders themselves w.r.t. to their placement.

For plot types, please add an image of how it should look like

E.g., I have this nice figure:

image

where the labels top right are added with

        Textbox(fig[i, j];
            placeholder = string(round(rmi; sigdigits = 2)),
            textcolor_placeholder = :black, valign = :top, halign = :right,
            tellwidth = false, tellheight=false, boxcolor = (:white, 0.75),
            textpadding = (5, 5, 5, 5)
        )

where i, j iterates over the 10 axes locations. I would like to add an additional padding that would place the textbox futher away from the axis splines. textpadding controls the distance between text and the textbox borders so it is not that.

jkrumbiegel commented 4 months ago

You could use alignmode = Outside(padding)

Datseris commented 4 months ago

Fantastic, thank you. However, I do not understand the interaction between alignmodel = Outside(padding) and textpadding. For example, I have this setup:

            textpadding = (2, 2, 2, 2),
            alignmode = Outside(0, 5, 0, 5)

which does not align things properly and the text gets cut off:

image

while, without setting alignmode at all, the text very nicely fits into the box with the same textpadding keyword:

image

jkrumbiegel commented 4 months ago

Ah ok then the alignmode seems to take away space from the inside. Hm I have to think about it