Skip to content

How to offset an axis label #1414

Open
@Fil

Description

@Fil

labelOffset moves the axis label in the direction orthogonal to the axis (say horizontally for the y axis). But how would you move it in the direction of the axis?

Suppose you want to move the axis label down (because there is a scale.insetTop or a large marginTop).

A hacky solution (implemented in https://observablehq.com/@recifs/a-centered-title) is an explicit label with lots of \n (spaces if working on the x axis)

Plot.axisY({ label: "\n\n\n\n\n↑ flipper_length_mm" }),

Similarly, a text mark with facetAnchor+frameAnchor.

Note: dy doesn't apply to the axis label (this is probably a bug in itself? this was intentional); if this worked, we could create a specific axis just for the label, and offset it. It would be tedious, but would benefit from the automatic label.

I think we should:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn’t workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions