Is it possible to add a custom text area (like a legend but I should be able to add my own text) in a python plotly plot ?
Yes, you can do this with a text annotation in paper coordinates. There is an example at https://plot.ly/python/text-and-annotations/#adding-annotations-with-xref-and-yref-as-paper where annotations are used as replacements for axis labels.
Also, if you need to have text spread across multiple lines you can add line breaks by inserting
Hope that helps!
I am a bit confused at the explanation you have given
Basically, I was looking for something similar across the lines of this image :
Here there are 2 text boxes besides the plot with some custom information. Is there a way to achieve something similar to this ?
Here’s a full example of what I was talking about:
import plotly.io as pio import plotly.graph_objs as go from plotly.offline import init_notebook_mode, iplot init_notebook_mode() fig = go.Figure( data=[ go.Scatter(y=[2, 1, 3]) ], layout=go.Layout( annotations=[ go.layout.Annotation( text='Some<br>multi-line<br>text', align='left', showarrow=False, xref='paper', yref='paper', x=1.1, y=0.8, bordercolor='black', borderwidth=1 ) ] ) ) iplot(fig)
Hope that helps,
Is it possible to embed more complex html in the text attribute ?
Here is the subset of HTML that is supported: https://help.plot.ly/adding-HTML-and-links-to-charts/.
@jmmease it looks like color isn’t supported?
Also, what is the role of the x, y coordinates? Based on your example above, they don’t appear to determine the location of the box.
Upon further exploration, it appears that they represent fractions of the plot e.g. if x=0.9, the x-coordinate of the box will start at the 90% of the width of the plot.