How to change textposition distance to the scatter point

Hi

Is there any method or feature to change the text position distance of go.Scatter3d()? the only options are what is show in the following but I need more closer!

( “top left”|“top center”|“top right”|“middle left”|“middle center”|“middle right”|“bottom left”|“bottom center”|“bottom right”` )

Hi @Bijan,

I used annotations to change my text positions. Here’s my approach:

import plotly.graph_objects as go
import numpy as np

#Example Data
x_data=[10,20,30]
y_data=[18,16,23]
z_data=[4, 10, 20]
text_data=["A","B","C"]

data_length = (len(x_data))

xshift = [0] * data_length #Position of the annotation (you can also create this for yshift) 
showarrow = [False] * data_length #No arrow
font_size = [18] * data_length #Annotation Fontsize


annotations = [dict(x=x, y=y, z=z, text=t, showarrow=i, xshift=j, font_size=k)
               for x, y, z, t, i, j, k in zip(x_data, y_data, z_data, text_data, showarrow, xshift, font_size)]

fig = go.Figure()
fig.add_trace(go.Scatter3d(
    x=x_data,
    y=y_data,
    z=z_data,
    text=text_data,
    mode='markers',
    marker=dict(size=25)))

fig.update_layout(

    scene=dict(
        annotations=annotations,
    ),
)

fig.show()

xshift = 0

xshift = 50

1 Like