Have latex (bold) and variable in legend of a figure
24 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Miraboreasu
am 26 Mai 2022
Kommentiert: Miraboreasu
am 27 Mai 2022
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1011560/image.png)
```
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 Kommentare
Akzeptierte Antwort
KSSV
am 26 Mai 2022
Bearbeitet: KSSV
am 26 Mai 2022
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 Kommentare
KSSV
am 27 Mai 2022
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)
Weitere Antworten (1)
Sam Chak
am 26 Mai 2022
Hi @Miraboreasu
I think this should work:
legend({'$\left[\frac{t v_{p}}{r_{well}}\right] \left(\Pi_{1}\right)$'}, 'Interpreter', 'latex', 'location', 'best')
Siehe auch
Kategorien
Mehr zu Legend finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!