Matlab注释中的Latex多行括号
我正在寻找一个用Matlab制作的带有括号的图形的注释,该括号将环绕3条线。链接图中给出了一个示例: 我成功地添加了第二个传奇。但我想知道我怎样才能做到干净。我试着做这样的事情Matlab注释中的Latex多行括号,matlab,latex,matlab-figure,legend,legend-properties,Matlab,Latex,Matlab Figure,Legend,Legend Properties,我正在寻找一个用Matlab制作的带有括号的图形的注释,该括号将环绕3条线。链接图中给出了一个示例: 我成功地添加了第二个传奇。但我想知道我怎样才能做到干净。我试着做这样的事情 str = '$S_n =$ $\left\{ \begin{tabular}{c} 0.5 MeV \\ 50 keV \\ 5 MeV \end{tabular}\right.$'; annotation('textbox',[0.325,0.175,0.1,0.1],'String',str,'Interprete
str = '$S_n =$ $\left\{ \begin{tabular}{c} 0.5 MeV \\ 50 keV \\ 5 MeV \end{tabular}\right.$';
annotation('textbox',[0.325,0.175,0.1,0.1],'String',str,'Interpreter','latex','FitBoxToText','on','Linestyle','none')
但这会产生这样的结果:
最大的问题是
我得检查一下注释的位置。。。但这没什么大不了的。我可以花一些时间把它定位得很好。
支架太大了。。。我没有办法解决这个问题。我怎么能这样做?
问题是:
这个括号可以缩小吗?
若否,可否以另一种方式进行?
就我个人而言,我认为括号看起来不错,担心确切的尺寸有点分散注意力 但是,另一个选项是为图例添加标题。 这将允许您表示每个图例所指的单位/参数,而不会弄乱图例的每一行。不幸的是,这不是一个原生的MATLAB功能,但我们可以强制它。具体实现因matlab版本而异 2014年前代码
function zz_LegendTitle(LegendHandle , TitleText, Fontsize)
% Workaround to Matlab 2014 thinking that legends don't need titles.
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ~exist('Fontsize','var'); Fontsize = 10; end
if ~exist('TitleText','var'); TitleText = 'example text'; end
% Create an invisible axes at the same position as the legend
hLegendAxes = axes('Parent',LegendHandle.Parent, 'Units',LegendHandle.Units, 'Position',LegendHandle.Position, ...
'XTick',[] ,'YTick',[], 'Color','none', 'YColor','none', 'XColor','none', 'HandleVisibility','off', 'HitTest','off');
% Add the axes title (will appear directly above the legend box)
hTitle = title(hLegendAxes, TitleText,...
'interpreter','latex',...
'FontWeight','normal',...
'FontSize',Fontsize); % Default is bold-11, which is too large
% Link between some property values of the legend and the new axes
hLinks = linkprop([LegendHandle,hLegendAxes], {'Units', 'Position', 'Visible'});
% persist hLinks, otherwise they will stop working when they go out of scope
setappdata(hLegendAxes, 'listeners', hLinks);
% Add destruction event listener (no need to persist here - this is done by addlistener)
addlistener(LegendHandle, 'ObjectBeingDestroyed', @(h,e)delete(hLegendAxes));
hLegend = legend(LegTxt,...
'interpreter','latex','FontSize',LegFontSize,...
'location','eastoutside');
%resize to fix the legend-enforced size change
set(ax(1),'Units',units,'position',IcePosVec);
%Attach a title to legend (here be dragons. Matlab 2015+ workaround)
hlt = text('some text',...
'Parent', hLegend.DecorationContainer, ...
'String', 'Title', ...
'HorizontalAlignment', 'center', ...
'VerticalAlignment', 'bottom', ...
'Position', [0.5, 1.05, 0], ...
'Units', 'normalized');
2014年后代码
function zz_LegendTitle(LegendHandle , TitleText, Fontsize)
% Workaround to Matlab 2014 thinking that legends don't need titles.
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ~exist('Fontsize','var'); Fontsize = 10; end
if ~exist('TitleText','var'); TitleText = 'example text'; end
% Create an invisible axes at the same position as the legend
hLegendAxes = axes('Parent',LegendHandle.Parent, 'Units',LegendHandle.Units, 'Position',LegendHandle.Position, ...
'XTick',[] ,'YTick',[], 'Color','none', 'YColor','none', 'XColor','none', 'HandleVisibility','off', 'HitTest','off');
% Add the axes title (will appear directly above the legend box)
hTitle = title(hLegendAxes, TitleText,...
'interpreter','latex',...
'FontWeight','normal',...
'FontSize',Fontsize); % Default is bold-11, which is too large
% Link between some property values of the legend and the new axes
hLinks = linkprop([LegendHandle,hLegendAxes], {'Units', 'Position', 'Visible'});
% persist hLinks, otherwise they will stop working when they go out of scope
setappdata(hLegendAxes, 'listeners', hLinks);
% Add destruction event listener (no need to persist here - this is done by addlistener)
addlistener(LegendHandle, 'ObjectBeingDestroyed', @(h,e)delete(hLegendAxes));
hLegend = legend(LegTxt,...
'interpreter','latex','FontSize',LegFontSize,...
'location','eastoutside');
%resize to fix the legend-enforced size change
set(ax(1),'Units',units,'position',IcePosVec);
%Attach a title to legend (here be dragons. Matlab 2015+ workaround)
hlt = text('some text',...
'Parent', hLegend.DecorationContainer, ...
'String', 'Title', ...
'HorizontalAlignment', 'center', ...
'VerticalAlignment', 'bottom', ...
'Position', [0.5, 1.05, 0], ...
'Units', 'normalized');
附言:值得表扬的地方,我大约在一年前写了这些代码,不知羞耻地从这个优秀的网站上盗取