Legend box impinges on legend text

1 view (last 30 days)
Braden
Braden on 23 Jun 2011
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?

Answers (1)

Paulo Silva
Paulo Silva on 23 Jun 2011
Have you tried with export_fig ?
  1 Comment
Braden
Braden on 24 Jun 2011
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

Sign in to comment.

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!