Designate legend text in Matlab

I have a legend shown below:

enter image description here

On the left, the text is aligned, but on the right, the numbers are not aligned. How can I also align the numbers?

+3


source to share


1 answer


The tab (\ t) command doesn't seem to work when providing rows for records in a table. However, you might be able to fix the problem if you are working in a latex environment, define each record as a one-line table form and define that the first column has a specific width (for example, 1 cm):

plot(eye(2)); % example plot
h=legend('\begin{tabular}{p{1cm}r}first:&1\end{tabular}',...
    '\begin{tabular}{p{1cm}r}second:&2\end{tabular}'); % table entries in latex
set(h,'interpreter','latex'); % set interpreter

      



enter image description here

+2


source







All Articles