我已经提供了一些替代方案,但对我来说,该项目符号似乎适用于列表中列出的特殊字符
link
你提到过。检查以下结果:
figure;
bar([1,2,3])
ylim([0 5]); text(1,2,'{\color{blue} apples} {\color{red} pears}');
annotation('textbox',[0.2 0.6 0.3 0.3],'String',{['{\color{blue}','\bullet','} yes'],...
['{\color{red}','\bullet','} no']},'FitBoxToText','on');
其中给出:
如果你是unicodes的粉丝,你会有更多的自由。您可以插入连字符(-)、em-dash()、square()、bullet()中的任意一个,然后列表继续。
char(8212)
给了他们冲刺,
char(9632)
给出平方,并且
char(8226)
给出子弹。你想用哪一个都行。
figure;
bar([1,2,3])
ylim([0 5]); text(1,2,'{\color{blue} apples} {\color{red} pears}');
annotation('textbox',[0.2 0.6 0.3 0.3],'String',{['{\color{blue}',char(8212),'} yes'],...
['{\color{red}',char(9632),'} no']},'FitBoxToText','on');
其中给出:
或者你可以操纵
legend
产生如下所示的所需结果:
figure;
plot(NaN,NaN,'b',NaN,NaN,'r'); hold on; %The trick
bar([1,2,3])
ylim([0 5]); text(1,2,'{\color{blue} apples} {\color{red} pears}');
legend({'yes','no'},'Location','northwest');
其中给出: