Matlab 如何在绘图中调整png图像尺寸

Matlab 如何在绘图中调整png图像尺寸,matlab,plot,Matlab,Plot,我已经设置了Latex作为plot的解释器。我注意到,如果我增加字体大小,png尺寸会增加(见下图)。我想在保存之前调整png的大小。这个问题有简单的解决办法吗?我看过plot Editor,但对该功能一无所知。我有多个图像,因此我希望它们具有相同的大小 您可以使用 set(gca, 'position', [left bottom width height]) 其中gca是轴手柄 e、 g 您可以尝试的一种方法是将地物数据保存为图像,然后裁剪出不需要的列。假设您的数字已经打开,您可以使用ge

我已经设置了Latex作为plot的解释器。我注意到,如果我增加字体大小,png尺寸会增加(见下图)。我想在保存之前调整png的大小。这个问题有简单的解决办法吗?我看过plot Editor,但对该功能一无所知。我有多个图像,因此我希望它们具有相同的大小


您可以使用

set(gca, 'position', [left bottom width height])
其中gca是轴手柄

e、 g


您可以尝试的一种方法是将地物数据保存为图像,然后裁剪出不需要的列。假设您的数字已经打开,您可以使用
getframe
cdata
习惯用法。但是,使用
cdata
只能获取图像内容本身。您还需要轴以及标签本身,因此您还需要捕获图形周围的边框。为了方便起见,我们将以像素为单位进行此操作。假设您的图像已打开,请执行以下操作:

ax = gca; %// Get current axes
ax.Units = 'pixels'; %// Set the axes units to Pixels
pos = ax.Position; %// Get position of figure

marg = 30; %// Get 30 pixel border around main content
rect = [-marg, -marg, pos(3)+2*marg, pos(4)+2*marg]; %// Define rectangle
F = getframe(gca,rect); %// Capture figure as image

%// Reset the axes back to what they were before (normalized)
ax.Units = 'normalized';

im = F.cdata; %// Get image

%// Show the image
figure;
imshow(im);

这将打开一个新的图形,它将裁剪出您不需要的内容。

您的Matlab版本是什么?版本是R2014a
ax = gca; %// Get current axes
ax.Units = 'pixels'; %// Set the axes units to Pixels
pos = ax.Position; %// Get position of figure

marg = 30; %// Get 30 pixel border around main content
rect = [-marg, -marg, pos(3)+2*marg, pos(4)+2*marg]; %// Define rectangle
F = getframe(gca,rect); %// Capture figure as image

%// Reset the axes back to what they were before (normalized)
ax.Units = 'normalized';

im = F.cdata; %// Get image

%// Show the image
figure;
imshow(im);