How to align multiline label and legend?
Hello
Using sprintf it is possible to create multiline labels in a legend. However, as shown in the example below, it would be better if the legend symbol (the colored line) would always be aligned with the first line of the multiline label, so aligned on top instead of being centered. The current output looks a bit confusing. Is it possible to control the position of the legend symbol w.r.t. the label?
Thanks in advance.
x=1:5;
y1=x;
y2=x.^2;
y3=x.^3;
plot(x,y1)
hold on
plot(x,y2)
plot(x,y3)
legend({‘first graph $y=x$’, sprintf(‘%sn%s’, ‘second graph’, ‘$y=x^2$’), sprintf(‘%sn%s’, ‘third graph’, ‘$y=x^3$’)}, ‘Interpreter’, ‘latex’)Hello
Using sprintf it is possible to create multiline labels in a legend. However, as shown in the example below, it would be better if the legend symbol (the colored line) would always be aligned with the first line of the multiline label, so aligned on top instead of being centered. The current output looks a bit confusing. Is it possible to control the position of the legend symbol w.r.t. the label?
Thanks in advance.
x=1:5;
y1=x;
y2=x.^2;
y3=x.^3;
plot(x,y1)
hold on
plot(x,y2)
plot(x,y3)
legend({‘first graph $y=x$’, sprintf(‘%sn%s’, ‘second graph’, ‘$y=x^2$’), sprintf(‘%sn%s’, ‘third graph’, ‘$y=x^3$’)}, ‘Interpreter’, ‘latex’) Hello
Using sprintf it is possible to create multiline labels in a legend. However, as shown in the example below, it would be better if the legend symbol (the colored line) would always be aligned with the first line of the multiline label, so aligned on top instead of being centered. The current output looks a bit confusing. Is it possible to control the position of the legend symbol w.r.t. the label?
Thanks in advance.
x=1:5;
y1=x;
y2=x.^2;
y3=x.^3;
plot(x,y1)
hold on
plot(x,y2)
plot(x,y3)
legend({‘first graph $y=x$’, sprintf(‘%sn%s’, ‘second graph’, ‘$y=x^2$’), sprintf(‘%sn%s’, ‘third graph’, ‘$y=x^3$’)}, ‘Interpreter’, ‘latex’) legend, multiline, align MATLAB Answers — New Questions