Skip to content

How to offset an axis label #1414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks done
Fil opened this issue Mar 31, 2023 · 1 comment · May be fixed by #1516
Open
2 tasks done

How to offset an axis label #1414

Fil opened this issue Mar 31, 2023 · 1 comment · May be fixed by #1516
Labels
bug Something isn’t working enhancement New feature or request

Comments

@Fil
Copy link
Contributor

Fil commented Mar 31, 2023

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:

@Fil Fil added bug Something isn’t working enhancement New feature or request labels Mar 31, 2023
@mbostock
Copy link
Member

Maybe the axis mark should support inset options so that you can move the axis label towards the center of the frame?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants