How can you reduce the spacing between the graph and the xaxis title position? I digged through the documentation to no avail.
Hi @mathieuboudreau,
Unfortunately I don’t think there are any options to set this spacing. The workaround is to use annotations in ‘paper’ coordinates. Here’s an example of doing just this for labeling axes (https://plot.ly/python/text-and-annotations/#adding-annotations-with-xref-and-yref-as-paper).
Hope that helps,
-Jon
Hii mathieu
i have one problem with charts
if i am using the ediatble true and rangeslider both togthere. Than if we edit the x-axis title then the are disappear. so please suggest me what to do.
And How the x-axis title show before rangeslider.
If someone’s searching for this solution , then it’s available now , use the ‘standoff’ property .
Something like this :
var layout = {
margin: {t:0,r:0,b:0,l:20},
xaxis: {
automargin: true,
tickangle: 90,
title: {
text: "Month",
standoff: 20
}},
yaxis: {
automargin: true,
tickangle: 90,
title: {
text: "Temprature",
standoff: 40
}}}
Does standoff
also work for the labels on the x-axis not just the title?
@windrose
No, you can only set xaxis_title_standoff=n_pixels
, to give the distance in pixels, between the axis labels and the title text.
You can set xaxis_ticklabelposition
but its effect is not we are expecting:
print(help(go.layout.XAxis.ticklabelposition))
Determines where tick labels are drawn with respect to the axis
Please note that top or bottom has no effect on x axes or when
`ticklabelmode` is set to "period". Similarly left or right has
no effect on y axes or when `ticklabelmode` is set to "period".
Has no effect on "multicategory" axes or when `tickson` is set
to "boundaries". When used on axes linked by `matches` or
`scaleanchor`, no extra padding for inside labels would be
added by autorange, so that the scales could match.
The 'ticklabelposition' property is an enumeration that may be specified as:
- One of the following enumeration values:
['outside', 'inside', 'outside top', 'inside top',
'outside left', 'inside left', 'outside right', 'inside
right', 'outside bottom', 'inside bottom']
You can inspect all xaxis properties printing:
help(go.layout.XAxis)
Thanks. It would be nice if it would be possible to control the positioning of the labels for the x and y-axis in a similar fashion as it is possible via standoff
for the title though, I think.
One hackish solution for moving x-axis labels lower (further away from plot), is to use fig.update_xaxes(tickprefix='<br>')
. But I 100% agree with @windrose, it would be great if x and y-axis labels had a standoff
parameter also.
I was trying to get some standoff between the plot and the labels but i couldn’t get it.
I totally agree with @johnnybarrels and @windrose about it.
in my opinion, it would be great that title and labels share the same standoff parameter…
Another hackish solution - I just used ticks="outside", tickcolor="white", ticklen=50
to move the y-axis labelling futher away from the y-axis, since the plot is on a white background the tickcolor
is invisible.