using CairoMakie
using GraphMakie
using Graphs
g = wheel_graph(10)
f, ax, p = graphplot(g)
hidedecorations!(ax); hidespines!(ax)
ax.aspect = DataAspect()
I managed to reduce the whitespace with the following code:
using CairoMakie
using GraphMakie
using Graphs
g = wheel_graph(10)
f, ax, p = graphplot(g)
hidedecorations!(ax); hidespines!(ax)
colsize!(f.layout, 1, Aspect(1, 1.0))
resize_to_layout!(f)
I guess this solution relies on knowing the aspect ratio of the plotted graph. I don’t know if there’s a more general solution.
My understanding (not an expert here!) is that the figure and the axis are distinct entities. In your example, the figure is initiated with a default size. We then adjust the aspect ratio, but this only affects the axis, not the figure, leaving quite a bit of whitespace.
That’s correct. When you give Axis an aspect, it just always resizes itself given the currently available space, but that’s after the layout is computed. So for resize_to_layout! the final size of the Axis is not known, so it cannot remove the whitespace. But giving rows or columns a fixed aspect ratio does let resize_to_layout! determine how much excess space there is.