필터 지우기
필터 지우기

Legend box impinges on legend text

조회 수: 2 (최근 30일)
Braden
Braden 2011년 6월 23일
I am having issues with the text inside a legend impinging on the box containing it when I print it to png. It does not look like that when it exists as a figure, only when I save it to file. It does not impinge on the legend box when the font is not changed. I would like to change the font to match my thesis. The legend text impinges on the box no matter how small I set the text to be. Is there any way to correct this?

답변 (1개)

Paulo Silva
Paulo Silva 2011년 6월 23일
Have you tried with export_fig ?
  댓글 수: 1
Braden
Braden 2011년 6월 24일
I downloaded export_fig after you suggested it. It has the same issues that Matlab does. This is the code I have to build the plot - perhaps I am changing the font in the wrong order or something?
load scatter_vars2
clf
% plot standard deviation
hStD = scatter(Synthesized387mU2U3EachTS,PwOutStDv,'<');
hold on
% plot min val
hPowMin = scatter(Synthesized387mU2U3EachTS,PwOutMinVal,'x');
% create filter
% A = Synthesized387mU2U3EachTS>=3.1;
B = and(Synthesized387mU2U3EachTS>=7, PwOutMaxVal<=1);
C = ~B;
% D = and(A==1,C==1);
% plot maximum power output
hPowMax = scatter(Synthesized387mU2U3EachTS(C),PwOutMaxVal(C));
% filter second set of data
B = and(Synthesized387mU2U3EachTS>=7, PwOut<=1);
C = ~B;
% plot average power output
hPow = scatter(Synthesized387mU2U3EachTS(C),PwOut(C),'+');
axis([0 20 -1 6]);
set(gca, ...
'Box' , 'off' , ...
'TickDir' , 'out' , ...
'TickLength' , [.02 .02] , ...
'XMinorTick' , 'on' , ...
'YMinorTick' , 'on' , ...
'YGrid' , 'on' , ...
'XColor' , [.3 .3 .3], ...
'XTick' , 0:1:20 , ...
'YColor' , [.3 .3 .3], ...
'YTick' , -1:0.5:6, ...
'LineWidth' , 1 );
hXLabel = xlabel('Hub Height Wind Speed (m/s)','FontName','Cambria');
hYLabel = ylabel('Measured Power (kW)','FontName','Cambria');
hLegend = legend([hStD, hPowMin, hPowMax, hPow],...
'Std. Dev ',...
'Minimum ',...
'Maximum ',...
'Average ',...
'location', 'NorthWest');
set([hLegend, gca] , ...
'FontSize' , 8 );
set([hXLabel, hYLabel],'FontName','Cambria');
set( gca , ...
'FontName' , 'Cambria' );
set(gcf, 'PaperPositionMode', 'auto');
%print the figure to file
print -dpng -r200 test.png

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by