Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Changing the xaxis title/label position?

How can you reduce the spacing between the graph and the xaxis title position? I digged through the documentation to no avail.

1 Like

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

2 Likes

Cool – that’s exactly the type of workaround I was looking for.

It worked perfectly!

A+

1 Like

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
        }}}
1 Like

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)

1 Like

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.