How to increase gap between axis title and axis in PlotlyJS?

Is there any parameter in PlotlyBase to set the gap between title of axis and axis.

Typically with log scaled axis my axis title (for y axis) is overlapping with “numbers”.

The Layout options that you want to play with are the margins, autoexpand, standoff, and automargin.

1 Like

Thank you for the links.

I have tried

layout = Layout(; margin_l = 100, margin_pad = 100)

But there was no effect. Please, could you help me with some working example?

To set some distance in pixels between xaxis ticklabels and xaxis title
you have to set xaxis_title_standoff=12 #(12 or another value by trial and error).
But the plotly docs say:

standoff
 |          Sets the standoff distance (in px) between the axis
 |          labels and the title text The default value is a
 |          function of the axis tick labels, the title `font.size`
 |          and the axis `linewidth`. Note that the axis title
 |          position is always constrained within the margins, so
 |          the actual standoff distance is always less than the
 |          set or default value. By setting `standoff` and turning
 |          on `automargin`, plotly.js will push the margins to fit
 |          the axis title at given standoff distance.

Hence try settings like in this example:

using PlotlyJS

pl= plot(scatter(x=1:5, y=3*rand(5), line_color="RoyalBlue"), 
         Layout(width=600, height=400,
                xaxis_title_text="X-TITLE",  xaxis_title_standoff=12, xaxis_automargin=true))
1 Like