- Theoretically, it does not make sense from a "grammar of graphics" approach.
- Pragmatically, whoever looks at the graphic and legend expects everything in the legend to be linked to a data element, so the viewer is going to be confused (if only briefly)
customize legend: extra legend entry
30 views (last 30 days)
Show older comments
On a first isight I didn't find the answere, but it might excist already. However to shorten things: I got the following legend:
legend({'Fit: $\arccos\left(\frac{\omega_0^2 - \omega^2}{\sqrt{(2\,\delta\,\omega)^2 + (\omega_0^2 - \omega^2)^2}}\right)$','Spulenstrom: 0,25 A','Fit:','Spulenstrom: 0,50 A','Fit','Spulenstrom: 1,50 A','Fit'},'Interpreter','latex','FontSize',16
Actually the first item doesn't belong to any graph, I made it visible by adding
fplot(w,'color',[1 1 1])
in front. However this isn't satisfying me, bc the entry is "sticking out". How can I indent it?
0 Comments
Accepted Answer
the cyclist
on 4 Jul 2020
"The first item doesn't belong to any graph" immediately indicates to me that this text does not belong in the legend, for two reasons:
So, it is no surprise to me that it would be difficult to make this work in MATLAB. (I don't know of a way to do it.)
I would think of this text as an annotation to the legend, and would therefore would create it separately, but nearby the legend. Here is one possible way to do that. (I just made up some nonsense data.)
rng default
figure
plot(rand(6))
legend({'Spulenstrom: 0,25 A','Fit:','Spulenstrom: 0,50 A','Fit','Spulenstrom: 1,50 A','Fit'},'Interpreter','latex','FontSize',16)
annotation('textbox',[0.57,0.5,0.1,0.1],'String', ...
'Fit: $\arccos\left(\frac{\omega_0^2 - \omega^2}{\sqrt{(2\,\delta\,\omega)^2 + (\omega_0^2 - \omega^2)^2}}\right)$', ...
'BackgroundColor','white','LineStyle','-','Fontsize',12,'Interpreter','latex')
More Answers (0)
See Also
Categories
Find more on Legend in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!