-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Configurable padding between axis title and label #4224
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
Comments
Related #3607 |
data / layout? |
I think this could be in |
Here's a first attempt: https://github.com/plotly/plotly.js/compare/axis-title-standoff where a new axis attribute called plotly.js/src/plots/cartesian/layout_attributes.js Lines 65 to 79 in 423c91b
It essentially exposes a way to override this computation: plotly.js/src/plots/cartesian/axes.js Lines 2708 to 2714 in 25fe1c9
A few notes:
|
Can this solution still guarantee that the axis title will not overlap with the tick labels? |
But we do do those computations when it isn't set? I'm confused. I was really expecting this to be a padding type thing around the title, even if we want to do the t/b/l/r thing... |
yes.
We compute the axis bounding boxes when:
otherwise we don't. |
OK, so the type of case that we'd like to address in this issue is this sort of thing: https://codepen.io/nicolaskruchten/pen/GRRpNjw?editors=0010 I'm not sure how the |
Here's one (not great) way: https://codepen.io/etpinard/pen/vYYNyJV?editors=0010 |
I agree this is "not great"... The goal for this issue is something that "just works" (including in |
All right, let's compute those bounding boxes then. I'm glad I asked. |
Me too :) sorry the original issue was not clear |
standoff doesn't seem to do anythign for me no matter what I set it to and yes I have automargin set. Was this ever implemented? The documentation has it so I assume it's in there. |
Yes, this was implemented and generally works for me... Can you provide a CodePen showing what's not working for you? |
Hmmm, I'm not too sure how to throw this into a codepen, but basically I have a bar chart that is 300px high with really long labels. So I set the automargin to true and the labels adjusted and looked better but they are really close to the x-axis label. I just wanted to offset the axis label by about 10-20px from the end of the tick labels. Here is my layout object: { |
I suspect that your "really" long x-axis labels are longer than half of the graph's height. If that's the case, we ignore them in the auto-margin computations. I'd recommend trying to increase your graph's |
Note also that |
@nicolaskruchten yup, understood, that's what I wanted to do. @etpinard - good to know. I had a feeling something like that may be occurring so I set the height to 700px and it still didn't work, but I may not have been using standoff properly at that time. I'll try again at 700px and let you know if I see any change. |
I've tried again with a height of 700px with no luck (only changes the size of the suplot). I changed the tick labels to be short and therefore go horizontally instead of on an angle and still can't seem to change the location of the x-axis label. Thanks for the responses, not sure what I'm doing wrong here, but I'll just have to live with the default for now I guess. |
Just thought of something, I'm using this in my package.json. Perhaps my version is too old? "plotly.js-basic-dist": "^1.49.4" |
Yup, that was the problem - you need to use the package that actually has the code lol... sorry about that, thanks for the replies! |
Was this propagated to coloraxes? |
It'd be nice if I could specify a "minimum padding between label & axis title". with automargin, they end up looking a little too tight:
related: #2575
The text was updated successfully, but these errors were encountered: