Matlab文本溢出了传奇

时间:2014-08-13 21:06:49

标签: matlab legend matlab-figure legend-properties

非常恼人,图表上有足够的尺寸来扩大图例,但它不会自动调整内容大小。有人建议如何解决这个问题? (乳胶翻译设置为传奇)

错误标记为红色,其中图例数据超出图例框

enter image description here

enter image description here

完全最小化我的问题的工作示例:

window=figure('Visible','on');
axes1 = axes('Parent',window);
grid(axes1,'on');
hold(axes1,'all');
set(window, 'Position', [0 0 1000 1000]);

x=rand(1000,1);
y=rand(1000,1);
companyMap='companyname of datapoint'

%draw scatter in window
scatter(x,y,'fill','MarkerFaceColor',[0,0,1],'MarkerEdgeColor',[0,0,1],'Marker','.','SizeData',30,'Parent',axes1,'DisplayName',sprintf('%s Datapoint',strrep(companyMap,'&','\&')));
linFit = fitlm(x,y);
dispName = sprintf('Linear fit: $y=%.3f x+ %.3f$, $R^{2}=%.3f$',linFit.Coefficients.Estimate(2),linFit.Coefficients.Estimate(1),linFit.Rsquared.Ordinary);
if linFit.Coefficients.Estimate(1) < 0
    dispName = strrep(dispName,'+','');
end
%lsline('linewidth',2,'Parent',axes1,'DisplayName',dispName);
line(x,linFit.Fitted,'Parent',axes1,'Tag','lsline','Color',[0 0 0],'DisplayName',dispName,'linewidth',2);
legend1 = legend(axes1,'show');
set(legend1,'Interpreter','latex');
%set(legend1, 'FontSize',7);
set(legend1,'Location','Best');

% Create title
title( { 'tit' }, 'FontSize',20);
% Create xlabel
xlabel( { 'x' } , 'FontSize',16, 'Interpreter','LaTex');
% Create ylabel
ylabel( { 'y' } , 'FontSize',16, 'Interpreter','LaTex');

1 个答案:

答案 0 :(得分:0)

解决方案集的工作示例(图例1,&#39;位置&#39;,[0.5 0.8 0.4 0.1])

window=figure('Visible','on');
axes1 = axes('Parent',window);
grid(axes1,'on');
hold(axes1,'all');
set(window, 'Position', [0 0 1000 1000]);

x=rand(1000,1);
y=rand(1000,1);
companyMap='companyname of datapoint'

%draw scatter in window
scatter(x,y,'fill','MarkerFaceColor',[0,0,1],'MarkerEdgeColor',[0,0,1],'Marker','.','SizeData',30,'Parent',axes1,'DisplayName',sprintf('%s Datapoint',strrep(companyMap,'&','\&')));
linFit = fitlm(x,y);
dispName = sprintf('Linear fit: $y=%.3f x+ %.3f$, $R^{2}=%.3f$',linFit.Coefficients.Estimate(2),linFit.Coefficients.Estimate(1),linFit.Rsquared.Ordinary);
if linFit.Coefficients.Estimate(1) < 0
    dispName = strrep(dispName,'+','');
end
%lsline('linewidth',2,'Parent',axes1,'DisplayName',dispName);
line(x,linFit.Fitted,'Parent',axes1,'Tag','lsline','Color',[0 0 0],'DisplayName',dispName,'linewidth',2);
legend1 = legend(axes1,'show');
set(legend1,'Interpreter','latex');
%set(legend1, 'FontSize',7);
set(legend1,'position',[0.5 0.8 0.4 0.1])

% Create title
title( { 'tit' }, 'FontSize',20);
% Create xlabel
xlabel( { 'x' } , 'FontSize',16, 'Interpreter','LaTex');
% Create ylabel
ylabel( { 'y' } , 'FontSize',16, 'Interpreter','LaTex');