Trying to get, e.g., two annotations to lay one next to/above/below the other on a figure using xref=‘paper’, but (0,0) and (1,1) in the paper domain correspond to the plottable area, not the entire figure. Since layout.height and layout.width set the pixel size of the figure, I need to figure out how to back out the actual pixel dimensions of the paper coordinates. I tried subtracting out the margins, but that’s still not quite right (see code and image below).
Anyone know how I can get the exact pixel dimensions of the “paper” domain?
ann_width=80
ann_height=20
left_px = 50
right_px = 50
top_px = 50
bottom_px = 50
W_px = 800
H_px = 600
ann_1 = go.layout.Annotation(
text='TEXT_A',
x=0,
y=0,
xref='paper',
yref='paper',
bordercolor='black',
borderwidth=1,
height=ann_height,
width=ann_width,
showarrow=False
)
ann_2 = go.layout.Annotation(
text='TEXT_B',
x=ann_width/(W_px-left_px-right_px),
y=0,
xref='paper',
yref='paper',
bordercolor='black',
borderwidth=1,
height=ann_height,
width=ann_width,
showarrow=False
)
fig_layout = go.Layout(
width=W_px,
height=H_px,
margin=dict(
l=left_px,
r=right_px,
t=top_px,
b=bottom_px,
),
annotations=[ann_1,ann_2]
)
fig = go.Figure(layout=fig_layout)
fig.show()