I want to add a variable, which is a common string, to LaTeX string:
Here’s the example:
import plotly.plotly as py
import plotly.graph_objs as go
a = 'ssss'
trace1 = go.Scatter(
x=[0, 1, 2, 3, 4, 5, 6, 7, 8],
y=[0, 3, 6, 4, 5, 2, 3, 5, 4],
name = '$\pm$'+a
)
trace2 = go.Scatter(
x=[0, 1, 2, 3, 4, 5, 6, 7, 8],
y=[0, 4, 7, 8, 3, 6, 3, 3, 4],
name=r'$\pm \text{{{}}}$'.format(a)
)
data = [trace1, trace2]
plotly.offline.plot(data, include_mathjax='cdn')
Here’s the result:
Using \text{{{}}}
isn’t convenient, is there any other possible method to add them together?