您好,我正在嘗試為情節上標一個字串。
hallo= str(round(popt[1],1))
plt.plot(xFit, func(xFit,*popt),color='r', linestyle='--',label=f'Ideales DOE 125 \u03bcJ <= 0,3 \u03bcm F(x) = {round(popt[0],1)} * e$^{hallo}*x$ ')
我得到的結果是:

“-0,2*x”應該是上標。我究竟做錯了什么?謝謝!
uj5u.com熱心網友回復:
它正在制作-上標。要在其中獲取整個運算式,您需要將整個運算式括在花括號中。既然你在 f 字串中有這個,花括號是有意義的,這意味著你需要這些相當笨拙的三重括號
plt.plot(xFit, func(xFit,*popt),color='r', linestyle='--',label=f'Ideales DOE 125 \u03bcJ <= 0,3 \u03bcm F(x) = {round(popt[0],1)} * e$^{{{hallo}}}*x$ ')
uj5u.com熱心網友回復:
我相信你需要用 $$ 包裹整個運算式,不能以 e$^10$ 開頭,而是 $e^10$
hallo = str(round(popt[1],1))
label = (f'Ideales DOE 125 \u03bcJ <= 0,3 \u03bcm '
f'F(x) = {round(popt[0],1)} * $e^{hallo}*x$ ')
plt.plot(xFit, func(xFit,*popt),color='r', linestyle='--',label=label)
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/457248.html
標籤:Python python-3.x matplotlib 上标
