保存两个可叠加的fig_uMATLAB

保存两个可叠加的fig_uMATLAB,matlab,position,size,figure,Matlab,Position,Size,Figure,我将两个matlab图形保存为png,我希望它们具有相同的大小,以便完全可叠加 第一个图形由函数“Filled Circle2”计算,该函数是一个用两种颜色分成两半的圆。 第二个图形由函数“Filled Circlel”计算,该函数是由函数“Filled Circle2”计算的圆的左半部分 我希望能够有两个数字,两个都有相同的大小,所以它们可以完美地叠加。 有人能帮我理解我做错了什么吗 以下是我的代码,包含两个函数和各自的输出: function []=FilledCircle2(x0,y0,R

我将两个matlab图形保存为png,我希望它们具有相同的大小,以便完全可叠加

第一个图形由函数“Filled Circle2”计算,该函数是一个用两种颜色分成两半的圆。 第二个图形由函数“Filled Circlel”计算,该函数是由函数“Filled Circle2”计算的圆的左半部分

我希望能够有两个数字,两个都有相同的大小,所以它们可以完美地叠加。 有人能帮我理解我做错了什么吗

以下是我的代码,包含两个函数和各自的输出:

function []=FilledCircle2(x0,y0,Radius,N, col1, col2)
if(N<=1)
    error('N must be greater than 1');
end
hold on
axis equal
axis off
hold on 

t=(0:N)*2*pi/N; %t=-pi:0.01:pi
x=Radius*cos(t)+x0;
y=Radius*sin(t)+y0;
plot(x,y)
hold on 

%Divide circle in to 2 equal parts
n=2;
thetas = linspace(-pi, pi,n+1); %linspace generates n points. The space between the points is [(pi/2)-(-pi/2)]/(n)

% Specify any colors wanted
colors = [col1; col2];

for k = 1:n
    tt = linspace(thetas(k), thetas(k+1));
    xi = Radius * cos(tt) + x0;
    yi = Radius * sin(tt) + y0;
    c2= fill([xi(:); x0], [yi(:); y0], colors(k,:)); %Assign diffrent colors to each circle 'slice'

    set (c2, 'edgecolor','white')
    set(c2,'LineWidth',2.0)

    set(gcf,'PaperUnits','inches','PaperSize',[0.8666,0.8666],'PaperPosition',[0 0 0.8666 0.8666])%setting size (130/150, 130/150, 150pixels per inch being the default size of img), paper position is imporrtant as otherwise i will have extra border
    set(gca, 'Position', [0 0 1 1]);
    set(gcf,'color',[0.49019607843137 0.49019607843137 0.49019607843137])%figure properties, rgb(125/255,125/255,125/255)
    fig = gcf;
    fig.InvertHardcopy = 'off'; %saves the fig with the set background color 

    %rotates the plot
    az= 90; %azimuth, az, is the horizontal rotation about the z axis as measured in degrees from the negative y-axis. Positive values indicate counterclockwise rotation 
    el= 90; % vertical elevation of the view point in degrees
    view(az,el);
    hold on
end
下面是函数
半填充圆(0,0,10300,'r')
的输出:


使用
xlim
ylim
设置轴的xy极限:

figure;
HalfFilledCircleL(0,0,10,300, 'r');
xlim([-12 12]);ylim([-12 12]);
az= -90; %azimuth, az, is the horizontal rotation about the z axis as measured in degrees from the negative y-axis. Positive values indicate counterclockwise rotation 
el= 90; % vertical elevation of the view point in degrees
view(az,el);

figure;
FilledCircle2(0,0,10,300, 'y', 'r');
xlim([-12 12]);ylim([-12 12]);

使用
xlim
ylim
设置轴的xy极限:

figure;
HalfFilledCircleL(0,0,10,300, 'r');
xlim([-12 12]);ylim([-12 12]);
az= -90; %azimuth, az, is the horizontal rotation about the z axis as measured in degrees from the negative y-axis. Positive values indicate counterclockwise rotation 
el= 90; % vertical elevation of the view point in degrees
view(az,el);

figure;
FilledCircle2(0,0,10,300, 'y', 'r');
xlim([-12 12]);ylim([-12 12]);

谢谢@user2999345!谢谢@user2999345!