# How to stick a colorbar to a scaled axis in Makie

**URL:** <https://discourse.julialang.org/t/how-to-stick-a-colorbar-to-a-scaled-axis-in-makie/70358>\
**Category:** Visualization\
**Tags:** plotting, makie, makielayout, colorbar\
**Created:** [October 25, 2021, 11:28pm UTC](https://discourse.julialang.org/t/how-to-stick-a-colorbar-to-a-scaled-axis-in-makie/70358 "2021-10-25T23:28:51Z")\
**Posts on this page:** 1\
**Showing post:** 7

<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:** [November 10, 2021, 2:29pm UTC](https://discourse.julialang.org/t/how-to-stick-a-colorbar-to-a-scaled-axis-in-makie/70358/7 "2021-11-10T14:29:28Z")

</div>

In GridLayoutBase 0.6.2, gridlayouts respect their alignments when they don’t reach the exact size that they should. So the example is now centered by default:

```julia
f = Figure(resolution=(1200,300))
Axis(f[1, 1])
Colorbar(f[1, 2])
colsize!(f.layout, 1, Aspect(1, 1))
f

```

 ![grafik](https://global.discourse-cdn.com/julialang/original/3X/7/2/728f5ce4376983d6466e62fdcb7d0d5630e8496c.png)

Also, with that rewrite I can soon add a function like `gridlayoutsize` or something to shrink the figure to the actually required size of the gridlayout, so if I manually add the outer padding just for this example, I get:

```julia
resize!(f.scene, gridlayoutsize(f.layout) .+ (32, 32))
f

```

![grafik](https://global.discourse-cdn.com/julialang/original/3X/a/4/a467e99a8a40d6d8354324b6ccfa019c46a57ae1.png)

---

_[View the full topic](https://discourse.julialang.org/t/how-to-stick-a-colorbar-to-a-scaled-axis-in-makie/70358)._
