My question in short can be seen in the figure. The numbers which are shown in the yellow box - how do I get them into Latex representation?
Long story or description:
You can see that, the x-axis (horizontal axis) is already displayed in Latex. Also, the \beta as the x-title, the vertical axis titles (x,y,z) and the labels are displayed using Latex.
Labels in Latex: Just have a look on the argument name in the following code
fig.append_trace(
go.Scatter(
x= mPVs,
y= dat[:,2],
name =r"$\text{z}$",
),
row=3, col=1)
Axes Titles : By the way, I do not like the pep8 style - I prefer start_Next_And_Next -style. I consider this type of coding to be less strenuous on the eyes.
def ticks_Modi(fig, ticks):
# get the ticks to Latex representation
ticks_Latex = [rf"${i:.3f}$" for i in ticks]
# generate empty dicts
tick_Coll = {
"yaxis1": {},
"yaxis2": {},
"yaxis3": {},
}
# horizontal axis -> get as latex
tick_Sett= {
"tickmode": 'array',
"tickvals": np.round(ticks, decimals = 3),
"ticktext": ticks_Latex
}
# vertical axes --> Latex, but HOW?
tick_Sett_Y = {
# "tickmode": 'array',
# "tickvals": np.round(ticks, decimals = 3),
# Plotly uses D3 -> also d3 formats doesent work here
"tickformat": r"$"+".0%"+r"$"
}
tick_Coll["xaxis1"] = tick_Sett
tick_Coll["yaxis1"] = tick_Sett_Y
# get the axis title to be in latex
tick_Coll["yaxis1"]["title"] = r"$\text{x}$"
tick_Coll["xaxis2"] = tick_Sett
tick_Coll["yaxis2"]["title"] = r"$\text{y}$"
tick_Coll["xaxis3"] = tick_Sett
tick_Coll["xaxis3"]["title"]= r"$\beta$"
tick_Coll["yaxis3"]["title"] = r"$\text{z}$"
# apply changes
fig.update_layout(tick_Coll)
return fig
What I also tried:
-
Try to access the original vertical axes numbers and then use โticktextโ. However, unfortunately I was not able to get the original vertical axes ticks โ see also: tickformat in Plotly Python
-
Ploty is build on d3 and if we apply โtickformatโ then the formatting abilities of d3 are invoked. Examples for that are given in:
Still, up to now I do not know a solution. The reason, why I need Latex is that I want to embed these plots in my thesis.
Thanks to everyone, who is willing to spend his time on my issue.