开发者

How can I change the axis (limits) while keeping the figure there, so that i can plot some other data on that figure for analysis?

开发者 https://www.devze.com 2023-03-15 10:47 出处:网络
I have been trying to see the trajectory of a point in julia set by first plotting the julia set as an image by the traditional escape velocity method and then plotting a point on the same curve, to s

I have been trying to see the trajectory of a point in julia set by first plotting the julia set as an image by the traditional escape velocity method and then plotting a point on the same curve, to see how they go to infinity, 0 or dance around.

Now the problem is that, when I plot the julia set as an image, the axis is turned to 0 to 300 and my complex numbers is -1+-1i to 1+1i so when i plot i cant see them as the way i want.

As a whole I want that when I plot a figure, i can extract that figure and paste it as is on a new axis and can then plot the new data on it.

I want to somehow change the axis to a new axis, while keeping the figure there without any change in it..

Here is the matlab code, I have been messing with..

figure;
hold on;
N =100
zMax = 1;
c = 0; %= 0.285+0.01i;
% julia
MAT=300;
mat=linspace(-zMax,zMax,MAT);
[MATx,MATy]=meshgrid(mat,mat);
Z=zeros(MAT,MAT);
M=zeros(MAT,MAT);
Z=MATx+i*MATy;
for k=1:MAT
    for j=1:MAT
        M(k,j)=escapeVelocity(Z(k,j),c,N);
    end
end
imagesc(atan(0.1*M));
axis xy;
xlabel('Re(z)'); ylabel('Im(z)');
colorbar;
%Now the main probelm exist. Whenever I try to plot Z it plots according to
%previous image axis which is from 0 开发者_如何转开发to 300.
Z0 = 0 + 1i;
Z=Z0;
for n= 1:N
    plot ((Z,'*','LineWidth',4);
    Z = Z^2 + c;
    pause
end


Oh, I think I see. You mean something like this:

figure;
N =100
zMax = 1;
c = 0; %= 0.285+0.01i;
% julia
MAT=300;
mat=linspace(-zMax,zMax,MAT);
[MATx,MATy]=meshgrid(mat,mat);
Z=zeros(MAT,MAT);
M=zeros(MAT,MAT);
Z=MATx+i*MATy;
for k=1:MAT
    for j=1:MAT
        M(k,j)=escapeVelocity(Z(k,j),c,N);
    end
end
a1 = axes;
imagesc(atan(0.1*M));
axis xy;
xlabel('Re(z)'); ylabel('Im(z)');
colorbar;
% get first axes on screen and settled
drawnow;
% create a 2nd axes on top of it
a2=axes('Position',get(a1,'Position'),'Visible','off');
hold on
Z0 = 0 + 1i;
Z=Z0;
h = plot(Z,'*','LineWidth',4,'Parent',a2);
for n= 1:N
    Z = Z^2 + c;
    set(h,'XData',real(Z),'YData',imag(Z));
    pause    
end

The basic idea is to create a second axes which is in the same place (the Position property) but doesn't have any decorations (Visible = 'off'), and then draw into that second one. You need that drawnow in there because the colorbar is going to jiggle the position of the first axes. You want to draw it to make sure that the position gets settled before copying it for the second axes.

Is that what you meant?


The plot command clears the axes, creates a line object, and returns a handle to that object. The simplest, and most efficient way to do what you want is to simply reuse the object it created. That'd look something like this:

for n = 1:N
    if n==1
        h=plot(Z,'*','LineWidth',4);
    else
        set(h,'XData',real(Z),'YData',imag(Z));
    end
    Z = Z^2 + c;
    pause;
end
0

精彩评论

暂无评论...
验证码 换一张
取 消