You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to draw a shape using the label argument to position the label outside of the shape. Unfortunately, the label always touches the shape and padding only works in one direction: towards the center of the shape.
Despite seting xanchor="left" and textposition="middle right", the label barely touches the shape (for padding=0) and with increasing padding the label always moves towards the center.
Setting padding to a negative value seems not to be allowed:
ValueError:
Invalidvalueof type 'builtins.int'receivedforthe'padding'propertyoflayout.shape.labelReceivedvalue: -10The'padding'propertyisanumberandmaybespecifiedas:
-Anintorfloatintheinterval [0, inf]
Expected Behavior
Either infer from anchor and textposition, if a label should be outside of the shape, or allow negative values for padding so that I can increase the distance between the rectangle and the label.
I could not find any other info regarding this observation and I would like to avoid using an annotation as a workaround.
Am I overlooking something or is this a bug?
System Info
python: v3.10.11
plotly: v5.24.1
Working in a VSCode (v1.96.2) notebook and tested multiple different renderers with identical outcome: "vscode", "notebook", "browser".
Same result with write_image and pdf and png.
The text was updated successfully, but these errors were encountered:
gvwilson
changed the title
Cannot increase distance between shape and it's label outside of the object
Cannot increase distance between shape and its label outside of the object
Jan 15, 2025
Challenge
I would like to draw a
shape
using thelabel
argument to position the label outside of the shape. Unfortunately, the label always touches the shape andpadding
only works in one direction: towards the center of the shape.Here is an example:
Despite seting
xanchor="left"
andtextposition="middle right"
, the label barely touches the shape (forpadding=0
) and with increasingpadding
the label always moves towards the center.Setting
padding
to a negative value seems not to be allowed:Expected Behavior
Either infer from
anchor
andtextposition
, if a label should be outside of the shape, or allow negative values forpadding
so that I can increase the distance between the rectangle and the label.I could not find any other info regarding this observation and I would like to avoid using an
annotation
as a workaround.Am I overlooking something or is this a bug?
System Info
python: v3.10.11
plotly: v5.24.1
Working in a VSCode (v1.96.2) notebook and tested multiple different renderers with identical outcome: "vscode", "notebook", "browser".
Same result with
write_image
andpdf
andpng
.The text was updated successfully, but these errors were encountered: