Reputation: 11
F=zeros(3,3);
F(1,:)=[0.3,0.35,0.2];
T=diag([0.2,0.5],-1);
P=(F+T)
X=[100;100;57]
plot2d([1,2,3],X)
for i=1:100
drawlater();
X=P*X;
clf;
plot2d([1,2,3],X)
drawnow();
end
scilab is constantly rescaling my animation. How to avoid rescaling ? Thanks in advance!
Upvotes: 0
Views: 239
Reputation: 3014
I would suggest this way of doing the animation, i.e. by using the data
field of Polyline
entity:
clf
plot2d([1,2,3],X)
h = gce().children
gca().data_bounds(3:4)=[1e-30,100];
gca().log_flags="nln"
for i=1:100
X=P*X;
h.data(:,2) = X;
sleep(100)
end
Without the sleep(100)
the animation is too fast...
Upvotes: 0
Reputation: 11
In addition to set the "data_bounds" as it was already given in another answer, you might have to set "tight_limits" to "on".
If tight_limits is "off", then the axis limits are not necessarily set to the values specified by data_bounds but may be set to a slightly larger range in order to achieve pretty tic labels.
Upvotes: 1
Reputation: 1010
Every time you call clf()
, current figure is cleared, therefore, there are no data boundaries set when plot2d()
is called. So for every pair clf() plot()
new boundaries are set, and the graph is re-scaled.
If you need the figure to be clear, and fixed boundaries, you have to set that axes property data_bound
using set()
in each loop:
set(gca(), 'data_bound', [x_min, y_min; x_max, y_max]);
I noticed your animation goes from 1 to 3 in X, and from 0 to 100 in Y, so you could write your loop like this:
plot2d([1,2,3],X)
for i=1:100
drawlater();
X=P*X;
clf();
plot2d([1,2,3],X)
set(gca(), 'data_bounds', [1, 0; 3 100]);
drawnow();
end
I also noticed the result is not good, but that's a problem with the data you're generating and the fixed scale you want, and not the animation "technique" itself.
Upvotes: 0