Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 更改ylim';子图的s_Matlab_Matlab Figure - Fatal编程技术网

Matlab 更改ylim';子图的s

Matlab 更改ylim';子图的s,matlab,matlab-figure,Matlab,Matlab Figure,我使用命令subplot(1,2,1)和subplot(1,2,2)对图形进行了分绘。我绘制了数据。如你所见,图中有两个图表 我想改变两个图的y轴的边界 例如,对于第一个图形,我有ylim=[0.5],对于第二个图形,我有ylim=[0.1.5]。我想更改这些ylim。首先,您需要访问您的体形: Myfig=gcf; %If the figure you want to modify is the current figure Myfig=figure(1); %Replace 1 by the

我使用命令
subplot(1,2,1)
subplot(1,2,2)
对图形进行了分绘。我绘制了数据。如你所见,图中有两个图表

我想改变两个图的y轴的边界


例如,对于第一个图形,我有
ylim=[0.5]
,对于第二个图形,我有
ylim=[0.1.5]
。我想更改这些ylim。

首先,您需要访问您的体形:

Myfig=gcf; %If the figure you want to modify is the current figure
Myfig=figure(1); %Replace 1 by the number of your figure, this command will make figure(1) your current figure and return its handle in Myfig.
现在,子图存储在图形的“Children”字段中。在这种情况下,它将是一个单元格数组,包含两个代表子图的轴对象

%If you don't have legends
Allsubplots=get(Myfig,'children'); 

% If you have legends, they will also appear as children of your fig
% Meaning you have to seek all fig's children that are of type 'axes'
Allsubplots=findobj(Myfig,'type','axes');

MySubplot1=Allsubplots(1);
MySubplot2=Allsubplots(2);

%%Change ylims of first subplot to [Ymin1 Ymax1] :
set(MySubplot1,'ylim',[Ymin1 Ymax1]);

%%Same for second subplot :
set(MySubplot2,'ylim',[Ymin2 Ymax2]);
更新:如果您已经事先知道要更改的子批次以及更改方式,要修改的图形是您当前的图形:

MySubplot1=subplot(1,2,1);
MySubplot2=subplot(1,2,2);

%%Change ylims of first subplot to [Ymin1 Ymax1] :
set(MySubplot1,'ylim',[Ymin1 Ymax1]);

%%Same for second subplot :
set(MySubplot2,'ylim',[Ymin2 Ymax2]);

谢谢,但它适用于第二个图形,而不是第一个。我有4x1双精度。我在情节中有传说。这可能是个问题吗?我的情节里有传说。可能是问题吗?是的,是的(尽管你仍然不应该有双倍,无论如何,我正在编辑我的答案),我想这样做,而不必再次绘制数据。如果我使用子绘图,我必须再次绘制数据。