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

35 visualizaciones (últimos 30 días)
Miraboreasu
Miraboreasu el 26 de Mayo de 2022
Comentada: Miraboreasu el 27 de Mayo de 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
```
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 comentarios
KSSV
KSSV el 26 de Mayo de 2022
What you want to display in legend?
Miraboreasu
Miraboreasu el 26 de Mayo de 2022
Editada: Miraboreasu el 26 de Mayo de 2022
Hello, you mean what is this latex for?
this, thank you

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 26 de Mayo de 2022
Editada: KSSV el 26 de Mayo de 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 comentarios
KSSV
KSSV el 27 de Mayo de 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)
Miraboreasu
Miraboreasu el 27 de Mayo de 2022
Thank you, but how to use the element from my array ```x```

Iniciar sesión para comentar.

Más respuestas (1)

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

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by