Qu

figure_size

Builtin index · Plotting

figure_size(w, h) or figure_size("ieee1")

Input: w, h · Output: no output

What it is

Sets canvas size either from w, h (numbers, raw units) or from a named journal-column preset string (e.g. "ieee1"). Type sizes scale with the square root of the area, so a figure shrunk to a column keeps its proportions.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
figure_size(w, h) or figure_size("ieee1")
w number or stringnot documented yet
h number or stringnot documented yet
no output"ieee1"). Type sizes scale with the square root of the area, so a figure shrunk to a column keeps its proportions.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

# A square canvas, so that equal ranges really are equal scales and the

# circle below comes out round. Without it the figure would render an

# ellipse while the paragraph above it explained how to avoid one.

figure_size(560, 560)
xlim(-2, 2)
ylim(-2, 2)
axis equal
circle(0, 0, 1, color = "royalblue", fill = "royalblue")
ellipse(0, 0, 1.6, 0.7, color = "crimson", rotate = 30)
arc(0, 0, 1.3, 0, 120, color = "seagreen", width = 2)
polygon([0.8, 1.6, 1.2], [-1.6, -1.6, -0.9], color = "purple", fill = "plum")
rectangle(-1.8, -1.8, -1.2, -1.2, color = "orange")
rect(1.0, -1.8, 1.8, -1.2, color = "teal")
point(0, 1.9)
-2.0 -1.5 -1.0 -0.5 0 0.5 1.0 1.5 2.0 -2.0 -1.5 -1.0 -0.5 0 0.5 1.0 1.5 2.0 (0, 1.9)

from plotting

How it works

figure_size(width, height) — sets the canvas savefig/ write_report/--emit-figure render at (Figure.width/ height, defaulting to DEFAULT_FIGURE_WIDTH/HEIGHT = 900x600, the size every export was unconditionally hardcoded to before this builtin existed — see those constants' doc Also rescales tick_size/label_size/title_size by sqrt((width*height) / (900*600)) off the DEFAULT sizes (not off whatever fontsize(...) may have already set — call fontsize(...) AFTER figure_size(...) if you want to override a specific size on top of the auto-scale). This matters because matplotlib/ggplot2/Plots.jl all default to *fixed* absolute font sizes regardless of figure size -- fine for them, since their fixed canvas size never actually varies without the caller consciously picking new sizes too. Qu had no figure-size knob at all before this builtin, so there was nothing to keep consistent; now that a script can ask for a tiny thumbnail or a huge poster-sized export, an absolute default would leave text either dominating a small canvas or vanishing on a big one, so this auto-scales by default instead. The area-based (not just height-based) formula means a much WIDER canvas at the same height grows fonts partially (by sqrt of the area ratio, so more room without literally doubling text for a merely-wider figure), while scaling both dimensions together (the "render at 2x resolution" case) scales fonts fully alongside it.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.