开发者

Matlab: y-label isn't shown in small figure window

I'm using the following code:

x = linspace(0, 9, 10);
y1 = x;
y2 = x.^2;
y3 = x.^4;

myfig = figure('Position', [500 500 400 320]); %[left, bot开发者_运维百科tom, width, height]:
ax1 = gca;
hold on
p1 = plot(x,y1,'x--r');
p2 = plot(x,y2,'*-b');

xlabel('blaaa');
ylabel('fooo'); 
xlim([0 max(x)]);
ax2 = axes('Position',get(ax1,'Position'),...
       'XAxisLocation','top',...
       'YAxisLocation','right',...
       'Color','none',...
       'XTickLabel', [],...
       'XColor','k','YColor','k');
ylabel(ax2, 'asdasd');
linkaxes([ax1 ax2],'x');
hold on
p3 = plot(x,y3,'s:g','Parent',ax2);

legend([p1 p2 p3], {'one', 'two', 'three'}, 'Location', 'NorthWest');

whereas the right y-label isnt shown: Is there a way to show it by decreasing either the margin between the left-edge and the left y-label or by decreasing the width of the actual plotted data without resizing the figure window?

Thanks

Edit: Added an image:

Matlab: y-label isn't shown in small figure window

Either decrease the red margin or the 'green' size, because wherre the blue arrow is, the y-label is now shown anymore since it doesn't fit!


Try replacing the line:

ax1 = gca;

with:

ax1 = axes('Position',[0.11 0.11 0.75 0.812]);

To manually set the axis position/size in normalized units.

Matlab: y-label isn't shown in small figure window

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜