-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Chart Title Alignment #882
Comments
Yeah. We should really add this. The reason why nobody has done this yet is that the plot title at the moment is set via two root Ideally, the main title should have its own layout object container, for example: layout.title = {
text: 'My title',
font: {
size: 20,
color: 'red'
},
x: 0,
y: 1.2,
xanchor: 'left',
yanchor: 'bottom',
}; similar to Moreover, axes titles (e.g. |
Any progress on this? |
Hey, I created an pr on that issue, could you please take a look? |
Thanks for taking this on @AlexVvx! I'm torn about the right way to specify alignment. I'm going to continue the discussion here for a bit until we get the right attributes. The closest precedent we have is to use plot fraction, like legend & annotations. But it's hard to match the current behavior:
The most common alternative title placement is in the top left corner (also whole-container referenced), but occasionally you want the left edges of the title and plot area aligned. Also keep in mind dynamic sizing, so pixel positioning isn't so great, unless perhaps we have a way to anchor to various plot features (left edge, left plot area edge, center, plot area center, right edge, right plot area edge...) So the most general is perhaps:
Thoughts? Does this miss anything important? Could it be simplified? |
I agree with @alexcjohnson that we should make the attributes as close as possible to the current I think both I like the sound of As for |
Good call. It feels awfully verbose to me, but it's going to come up at some point so better to standardize. OK, I think we've got a good attribute set, @AlexVvx does this make sense? Care to take a stab at incorporating this into your PR? |
Sure, sounds good. Summarizing:
Backward compatibility, skip new features if title is string (from https://community.plot.ly/t/change-position-of-title/1490/3) |
Right, not axes but whether x/y refer to the plot area (excluding margins) or the whole container (including margins). By default it should be the whole container, for backward compatibility and because that seems like the more common usage anyhow, for both centered and left-aligned titles.
We should use The only issue I see with this is that applications using Also, from a private convo with @etpinard - it might be nice to have |
Ok, then:
I wonder about pad, if xanchor and yanchor is center/middle, should it respect paddings? |
I know it doesn't make the most sense considering only this context, but I think we should match the other |
@AlexVvx apologies, I missed these pieces earlier:
In this case since there's no border or fill (yet?) paddings are only going to be relevant on the same side as the anchor, so you're right, it's moot for center and middle.
From @etpinard above:
ie the anchor shifts to match the nearest third of the plot. |
Thank you, one more question regarding picture below. Red rectangle is container, black is 'paper'. I wonder if title will be in the center of paper, on the top of traces. Is that expected? |
See below: Red is You're right, it would be weird to put the title in the middle, though maybe there would be uses for it - like if you make a donut chart and want the title in the hole? The main use for title: {
text: 'Paper-referenced title',
xanchor: 'left', // or 'auto', which matches 'left' in this case
yanchor: 'bottom',
x: 0,
y: 1,
xref: 'paper',
yref: 'paper'
} |
cc @rmoestl |
Okay to apply this change to |
Yep, go for it. Ternary axes should use the new structure too. |
... and gl3d axes as well. |
Alright. BTW |
👍 |
Done in #3276 ! |
Would it be possible to provide alignment API for chart title, "left", "center" "right" ?
The text was updated successfully, but these errors were encountered: