Have latex (bold) and variable in legend of a figure

조회 수: 31 (최근 30일)
Miraboreasu
Miraboreasu 2022년 5월 26일
댓글: Miraboreasu 2022년 5월 27일
Hello,
I have two lines in one figure, one is called error, and the other is typed by latex form as well as the first element of array ```x```, but I tried to use sprintf, but the results are wierd
```
x=[1.1, 2.1, 3.1]
legend( 'Error',sprintf('\bf[$\bf\frac{t v_p}{r_{well}}$] (\bf$\Pi_1$) = %f', x(1)), 'Location','best','Interpreter','latex' )
```
  댓글 수: 2
KSSV
KSSV 2022년 5월 26일
What you want to display in legend?
Miraboreasu
Miraboreasu 2022년 5월 26일
편집: Miraboreasu 2022년 5월 26일
Hello, you mean what is this latex for?
this, thank you

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2022년 5월 26일
편집: KSSV 2022년 5월 26일
plot(rand(1,10)) ;
hold on
plot(rand(1,10)) ;
legend( 'Error','$[\frac{tv_p}{r_{well}}](\Pi_1=)$','Interpreter','latex', 'Location','best')
set(gca,'FontSize',24)
  댓글 수: 3
KSSV
KSSV 2022년 5월 27일
plot(rand(1,10)) ;
hold on
plot(rand(1,10)) ;
legend( '\bf Error','$\bf [\frac{tv_p}{r_{well}}](\Pi_1=)$','Interpreter','latex', 'Location','best')
set(gca,'FontSize',24)
Miraboreasu
Miraboreasu 2022년 5월 27일
Thank you, but how to use the element from my array ```x```

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sam Chak
Sam Chak 2022년 5월 26일
I think this should work:
legend({'$\left[\frac{t v_{p}}{r_{well}}\right] \left(\Pi_{1}\right)$'}, 'Interpreter', 'latex', 'location', 'best')

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by