[Scilab-users] Finding data_bounds
Antoine Monmayrant
antoine.monmayrant at laas.fr
Tue Mar 22 12:17:24 CET 2016
Le 03/22/2016 11:39 AM, Jens a écrit :
> xdel();
> figure('BackgroundColor',[1 1 1]);
> f1=gcf(); f1.figure_size=[1000 900]; f1.figure_position = [300,0];
>
> subplot(2,3,1)//setting estimated plot bounds to maintain during loop
> cafix=gca();
> cafix.data_bounds = 5*[-1,-1;1,1];// estimated values before calculation
> cafix.tight_limits="on";
> cafix.auto_scale="off";
>
>
> x=linspace(-5,5,10);//calculate and plot
> for i=1:5
> subplot(2,3,1)
> plot(cafix,x,i*x/2)
> //further calculations and subplots here
> subplot(2,3,1)
> plot(cafix,x,i*x/2,'-o')
> //further calculations and subplots here
> subplot(2,3,1)
> plot(cafix,x,i*x/2,'-+')
> end//for ...
> sleep(2000)
> //Now Scilab knows the extremal values which should become visible too
> now if cropped.
> subplot(2,3,1)
> cafix.isoview="on";
> cafix.axes_bounds = [0,0,0.4,0.4];
> cafix.data_bounds = 13*[-1,-1;1,1];//These bounds are set by inspection
> //How can adequate data_bounds be extracted from the graphic object?
Just add the following at the end of your script:
nplot=length(cafix.children);
xs=[];
ys=[];
for i=1:nplot
xs=[xs;cafix.children(i).children.data(:,1)];
ys=[ys;cafix.children(i).children.data(:,2)];
end
xmin=min(xs);
xmax=max(xs);
ymin=min(ys);
ymax=max(ys);
cafix.data_bounds=[xmin,xmax,ymin,ymax]
By the way, is there any reason to overlap several plots instead of
adding new points in the previous one?
This would be more efficient:
cafix.children(1).children.data=[cafix.children(1).children.data;[new_xs,new_ys]];
cafix.tight_limits="on";
Cheers,
Antoine
More information about the users
mailing list