# Minimum size of Makie grid cell?

**URL:** <https://discourse.julialang.org/t/minimum-size-of-makie-grid-cell/67082>\
**Category:** Specific Domains\
**Tags:** makie, makielayout\
**Created:** [August 27, 2021, 6:53am UTC](https://discourse.julialang.org/t/minimum-size-of-makie-grid-cell/67082 "2021-08-27T06:53:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RainerHeintzmann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rainerheintzmann/32/19726_2.png) [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Post date:** [August 27, 2021, 6:53am UTC](https://discourse.julialang.org/t/minimum-size-of-makie-grid-cell/67082/1 "2021-08-27T06:53:30Z")

</div>

I am layouting a `Makie.jl` figure with some figure elements (at `[1,1]`, `[2,1]` and `[1,2]`) and a text box (at `[2,2]`). The text box is created as well as an axis and the text is written (a little painfully) into it. To get a well-behaved layout, I am currently using `rowsize!` and `colsize!` and specifying fixed sizes for the text part at figure startup in case the corresponding graphic needs too little space but else the colums and rows only get assigned relative widths and heights.

Yet, this does not behave well if the user resizes the whole figure. Therefore it would be very useful to specify something like `MinSize(200)` as a `ContentSize` as a 3rd argument to `colsize!()`. Is something like this possible? Even better, is it possible to force the text box to adapt to a minimum such that the text is always fully displayed (since different users may want different font sizes, etc.).

So far I am hacking via `ax.layoutobservables.computedbbox.val.widths` into the layout system to get an idea what the size of the current axis is, but I was having some trouble with the column size in which case it was consistently larger than what was set via `colsize!()` at the cell corresponding to that axis. Is there a better way to determine the size a figure cell in grid layout currently occupies?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [August 27, 2021, 7:12am UTC](https://discourse.julialang.org/t/minimum-size-of-makie-grid-cell/67082/2 "2021-08-27T07:12:55Z")

</div>

I don’t quite understand your issue, maybe an image would help. There’s currently no way to specify min or max sizes, that could be a useful addition to GridLayoutBase. You can give the Textbox a fixed width, too, you don’t have to do that through colsize!

---

<div class="post-metadata">

**Author:** ![RainerHeintzmann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rainerheintzmann/32/19726_2.png) [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Post date:** [August 27, 2021, 8:07am UTC](https://discourse.julialang.org/t/minimum-size-of-makie-grid-cell/67082/3 "2021-08-27T08:07:20Z")

</div>

Yes, a minimum (and maximum?) size option might be a useful addition for layouting. As for the textbox, used for information display only (!), maybe I am constructing it entirely the wrong way:

```julia
ax_txt = Axis(fig[2,1], backgroundcolor=:white, xzoomlock=true, yzoomlock=true, xpanlock=true, ypanlock=true, xrectzoom=false, yrectzoom=false) 
hidedecorations!(ax_txt, grid = false); ax_im.xrectzoom = false; ax_im.yrectzoom = false
xlims!(ax_txt,-4,100); ylims!(ax_txt,-4,100)
text!(ax_txt, text_to_display, position = Point(0,99), color = :black, align = (:left, :top), justification = :left)

```

Maybe one could use the existing `Textbox` instead? But then how do I use it for display and disable user interaction?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [August 27, 2021, 8:32am UTC](https://discourse.julialang.org/t/minimum-size-of-makie-grid-cell/67082/4 "2021-08-27T08:32:52Z")

</div>

Why don’t you use a Label for that which is just text?

---

<div class="post-metadata">

**Author:** ![RainerHeintzmann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rainerheintzmann/32/19726_2.png) [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Post date:** [August 27, 2021, 4:50pm UTC](https://discourse.julialang.org/t/minimum-size-of-makie-grid-cell/67082/5 "2021-08-27T16:50:20Z")

</div>

Great. This is what I was looking for.

```julia
using GLMakie
fig = Figure()
plot(fig[1,1],sin.(1:0.1:10), color=:red)
lab = Label(fig[2,1],"Hello World!\nThis Label autoexpands!", halign = :left, valign = :top)

```

Its working fine 🙂
