首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Matlab:重叠子图标题

Matlab:重叠子图标题
EN

Stack Overflow用户
提问于 2013-05-24 04:18:58
回答 5查看 10.4K关注 0票数 3

我使用的是subplot,它包含三个不同的图。每个绘图都有自己的标签和标题。

问题是,当我保存它时,我必须最大化它。否则,文本将相互重叠。

当我将其最大化时,即使我使用ESP格式或任何矢量格式,子图的标签文本在图像中也会显示得有点模糊。

如何解决此问题?

EN

回答 5

Stack Overflow用户

发布于 2013-05-24 04:31:13

对于标题重叠问题,您可以使用字符串单元格数组作为title ()的输入参数来生成多行标题文本:

代码语言:javascript
复制
title_text = {'first line', 'second line', 'third line'};
title(title_text);

它也适用于标签文本。

票数 5
EN

Stack Overflow用户

发布于 2013-05-24 04:38:56

除了大广的回答之外,如果你想保持你的标题和标签在同一行,你可以改变字体大小

代码语言:javascript
复制
a = axes;
t = title('My Really Long Title');
l = xlabel('My Really Long x label')
set(t, 'FontSize', 8)
set(l, 'FontSize', 8)
票数 2
EN

Stack Overflow用户

发布于 2013-05-24 05:30:58

我不确定为什么你的标签是模糊的,但我可以帮助你解决重叠问题。

当我想保存图像时,我从不使用subplot。一篇论文)。我所做的是单独创建每个轴,这允许对每个轴进行更多的控制。

下面是一个相当普遍的例子,它说明了如何生成任意的轴网格线,并对其位置进行比subplot允许的更精细的控制。当然,只有3个轴,你并不真的需要循环,但我相信你可以调整它来满足你的需要。

代码语言:javascript
复制
% first create the figure
figPos = [200 200 800 500];
figure('Color', 'w', 'Position', figPos)

% next, determine how much padding you want on each side of the axes, and in
% between axes. I usually play around with these, and the figure size until
% the layout looks correct.

leftPadding = 50/figPos(3); % the space at the left of the figure
rightPadding = 25/figPos(3); % the space at the right of the figure
horizPadding = 80/figPos(3); % the space between axes (horizontally)
topPadding = 30/figPos(4); % the space at the top of the figure
bottomPadding = 50/figPos(4); % the space at the bottom of the figure
vertPadding = 120/figPos(4); % the space between axes (vertically)

% set up the grid size
nHorizAxes = 2;
nVertAxes = 3;

% figure out how big each axes should be
horizPlotSpace = 1-leftPadding-rightPadding-(nHorizAxes-1)*horizPadding;
vertPlotSpace = 1-topPadding-bottomPadding-(nVertAxes-1)*vertPadding;
width = horizPlotSpace/nHorizAxes;
height = vertPlotSpace/nVertAxes;

myAxes = zeros(nVertAxes, nHorizAxes);

% create some sample data to plot for illustrative purposes
x = linspace(0, 2*pi);
y = sin(x);

for iRow = 1:nVertAxes
    for iCol = 1:nHorizAxes
        % calculate the position
        left = leftPadding+(iCol-1)*(width+horizPadding);
        bottom = bottomPadding+(iRow-1)*(height+vertPadding);
        position = [left bottom width height];

        myAxes(iRow, iCol) = axes('Position', position);
        plot(x, y)
        xlabel('Test Label')
        ylabel('Test Label')
        title(sprintf('axes(%d, %d)', iRow, iCol))
    end
end
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16723146

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档