twiny_top_offset_px Function

public pure function twiny_top_offset_px(dpi, has_top_xlabel) result(offset)

Extra image pixels to push the plot-area top edge down for a twiny (top x-axis), beyond the default top margin.

The raster/PDF backends stack the top band upward from the plot-area top edge as: top tick labels, then the top axis label, then the title. Without a twiny only the title sits above the axes, and the default top margin already holds it inside the canvas. A twiny inserts the tick labels and the top axis label below the title, so the stack grows and the upper elements clip at y=0. This returns that added height.

Tick and axis label heights match DEFAULT_FONT_SIZE points scaled to device pixels by DPI; pads match the constants the label placement applies (X_TICK_LABEL_TOP_PAD, CANVAS_EDGE_PADDING_PX). The added TITLE_VERTICAL_OFFSET is the gap the title now needs above the top-axis block. The title's own height is not added: the default top margin already reserves it, and with a twiny the title simply moves from just above the axes to the top of this taller stack.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: dpi
logical, intent(in) :: has_top_xlabel

Return Value integer