在MATLAB中使用set(gca,';LineWidth';x)创建一个新图形,而原始图像具有默认宽度

在MATLAB中使用set(gca,';LineWidth';x)创建一个新图形,而原始图像具有默认宽度,matlab,matlab-figure,Matlab,Matlab Figure,我在我的图形代码中使用set(gca,'LineWidth',2),并获得两幅图像。原始图像是相同的,但第二个图像只有一个宽度为2的轴。我的代码如下 clc; clear all ; set(gca,'LineWidth',2) figure('DefaultAxesFontSize',30); set(0,'DefaultAxesFontName',' Times '); hold on x1 =10:10:3000; % % ---------- reading data --

我在我的图形代码中使用
set(gca,'LineWidth',2)
,并获得两幅图像。原始图像是相同的,但第二个图像只有一个宽度为2的轴。我的代码如下

clc; clear all ;

 set(gca,'LineWidth',2)

figure('DefaultAxesFontSize',30);
set(0,'DefaultAxesFontName',' Times  ');

hold on 
x1 =10:10:3000;

% % ---------- reading data -------%

arrival_rate = xlsread('scep.xlsx', 'comparing_thoughput_for123',   'A3:A10');
one_stream = xlsread('scep.xlsx', 'comparing_thoughput_for123',  'B3:B10');
two_stream = xlsread('scep.xlsx', 'comparing_thoughput_for123',      'C3:C10');


 x2 = interp1(arrival_rate,one_stream,x1,'pchip') ;
 x3 = interp1(arrival_rate,two_stream,x1,'pchip') ;

                    %    plotting throughput

%                          ------scep qos1 one_stream ------
plota = plot(x1,x2,'r-','DisplayName', ' Single Stream ', 'LineWidth',1);
plot(arrival_rate,one_stream,'ro', 'HandleVisibility','off','LineWidth',2);


%                          ------scep qos1 two_stream ------
plot(x1,x3,'b-','DisplayName', ' Two Streams ', 'LineWidth',1);
plot(arrival_rate,two_stream,'bs', 'HandleVisibility','off','LineWidth',2);


xlabel('\lambda (events/second)')
ylabel('Thoughput (events/second)')
legend('Location','northwest')
legend show

% title('Effect of arrival rate on average CEP throughput')

% set(gcf, 'LineLineWidth', 2);

set(gcf, 'PaperUnits', 'normalized');
set(gcf, 'PaperPosition', [0 0 1 1]);
set(gcf,'PaperOrientation','l');

print -dpdf  graphs/comparing_thoughput ;

我做错了什么?

首先创建您的体形,然后设置其中的属性:

figure;
set(gca, 'FontSize',30, 'FontName','Times')
set(gca, 'LineWidth',2)
请注意,在没有图形的情况下,
gcf
gca
创建一个图形,以便它们可以返回有效的句柄。因此,在您的代码中,您的第一个
集合(gca,…)
创建了一个带有轴的图形,然后您调用
图形
,这将创建另一个图形