0

Using matplotlib one can place a latex-formatted table directly within a plot. In plotly, I know that a table can be added as a subplot, but is there a way to add a latex table within a single plotly plot (i.e., without creating a separate subplot for the table)? When I use annotations as below:

from plotly import graph_objects as go
fig = go.Figure()
fig.add_trace(go.Scatter(
                    y=[1,2,3,4,5,4,3,2,1,1,1,1,1,1,1,1], name="plot 1"
                ))
fig['data'][0]['showlegend']=True

table = r'''\begin{tabular}{ c | c | c | c } & col1 & col2 & col3 \\\hline row1 & 11 & 12 & 13 \\\hline row2 & 21 & 22 & 23 \\\hline  row3 & 31 & 32 & 33 \end{tabular}'''
fig.add_annotation(
    dict(x=0.55, y=.8, showarrow=False, text=table, xref="paper", yref="paper")
)
fig.show()

the table is not rendered.

rhz
  • 780
  • 8
  • 19

0 Answers0