Make_subplots: x_title and y_title locations

Using make_subplots, the y_title field is too far left and is being cut off in the middle and the x_title is also located too low.

julia> fig = make_subplots(rows=1, cols=3, y_title=“test y”, x_title=“test x y j p q”)
Here’s a png capture of the output window:

Does anyone know how to adjust them? The locations are fine using the python version: plotly.subplots.make_subplots().

@kfranke
This position of x_title is set a bit apart from axes in: [https://github.com/sglyon/PlotlyBase.jl/blob/master/src/subplots.jl#L544(https://github.com/sglyon/PlotlyBase.jl/blob/master/src/subplots.jl#L544)
and a few lines below are given settings for y_title.
More precisely, there is a big value for annotation xshift for y_title, respectively yshift for x_title.
Here you can find what is meant by xshift, respectively yshift:
https://plotly.com/julia/reference/layout/annotations/#layout-annotations-items-annotation-xshift.
How we can update their values? For, let us consider the following example:

using PlotlyJS
fig  = make_subplots(rows=1, cols=2,  x_title="this is x_title", y_title="my ytitle")
add_trace!(fig, scatter(
    x=[0, 1, 2, 3, 4, 5, 6, 7, 8],
    y=[0, 1, 3, 2, 4, 3, 4, 6, 5]), row=1, col=1)
add_trace!(fig, scatter(
    x=[0, 1, 2, 3, 4, 5, 6, 7, 8],
    y=[0, 4, 5, 1, 2, 2, 3, 4, 2]), row=1, col=2)

relayout!(fig, width=700, height=350)
#fig.plot.layout.annotations[1].yshift=-15
#fig.plot.layout.annotations[2].xshift=-18
display(fig)

To detect the index of annotations corresponding to x_title, y_title, print all annotations:

print(json(fig.plot.layout.annotations, 2))

Here we have only two annotations (but setting in make_subplots the subplot_titles, too, as well as any other annotation, leads to a bigger number of annotations).
To reduce the distance of these titles from the axes we must update the annotations. I couldn’t figure out how can be performed annotation update via relayout!. That’s why I added the two commented lines in the above example. If you are uncommenting them you’ll get a better position for axis titles.

2 Likes