我正在尝试创建一个等高线图(带有颜色条),其轮廓图完全是方形的,用于美学/数据解释的原因。
示例代码:
x=-10:10;
y=-10:10;
[X Y] = meshgrid(x,y);
f = figure('Visible','off');
contour(X,Y,X.*Y,'Fill','on');
colorbar
x_size = 10;
y_size = 10;
set(f, 'PaperUnits', 'inches','PaperPosition',[0 0 x_size y_size]);
print(f, '-depsc2','notsquare.eps);
有没有办法控制轮廓图区域的尺寸,使其完全正方形?
答案 0 :(得分:2)
这对我有用(添加axis equal
):
x=-10:10;
y=-10:10;
[X Y] = meshgrid(x,y);
f = figure('Visible','off');
contour(X,Y,X.*Y,'Fill','on');
colorbar, axis equal
x_size = 10;
y_size = 10;
set(f, 'PaperUnits', 'inches','PaperPosition',[0 0 x_size y_size]);
print(f, '-depsc2','square.eps');