I've made 2 plot in one axes using pushbutton in matlab guide, the first plot is line plot
here is the plot
http://i1275.photobucket.com/albums/y443/Kaito_Aokage/Capture2_zpsbc76be37.png?t=1403148417
code for line plot
% X
for i = 1.5:7;
cur_x = i * 3.8;
line([cur_x, cur_x], [0 5], 'color', 'r', 'LineWidth', 1.5);
drawnow;
end;
% Y
for i = 2:7;
cur_y = i * 4;
line([0 4],[cur_y, cur_y], 'color', 'r', 'LineWidth', 1.5);
drawnow;
end;
% X2
for i = 1.5:7;
cur_x2 = i * 3.8;
line([cur_x2, cur_x2], [25 31], 'color', 'r', 'LineWidth', 1.5);
drawnow;
end;
% Y2
for i = 1:8;
cur_y2 = i * 3.5;
line([26 31],[cur_y2, cur_y2], 'color', 'r', 'LineWidth', 1.5);
drawnow;
end;
% X
line( [5.7 cur_x], [5 5], 'color', 'r', 'LineWidth', 1.5);
% Y
line( [4 4], [8 cur_y], 'color', 'r', 'LineWidth', 1.5);
% X2
line( [5.6 cur_x2], [25 25], 'color', 'r', 'LineWidth', 1.5);
% Y2
line( [26 26], [3.5 cur_y2], 'color', 'r', 'LineWidth', 1.5);
handles.axes2;
grid on;
hold on;
axis([0 30 0 30]);
and the second plot is contour plot
http://i1275.photobucket.com/albums/y443/Kaito_Aokage/Capture3_zpsfd46dedf.png?t=1403148576
code for contour plot
xMove = 3;
yMove = 10;
r = 30;
rx = -r:0.1:r;
ry = r:-0.1:-r;
[x_coor, y_coor] = meshgrid(rx, ry);
radius = sqrt(x_coor.^2+y_coor.^2);
contourf(x_coor + xMove, y_coor + yMove, radius,'edgecolor','none');
xlabel('Widht');
ylabel('Long');
axis([0 30 0 30]);
colorbar;
caxis([0 10]);
grid on;
handles.axes2;
set(gca,'layer','top');
hold on;
Pushbutton Floor is line plot and Pushbutton AP1 is contour plot. When i try to push plot contour button after line plot button, the line plot overlap by contour plot. I want line plot doesn't overlap by contour plot so the line plot can be seen after i push contour plot button. I already try hold
or set(gca,'layer','top)
but its not working. what should i do?
in what order are you executing the above codes ? I first executed second code then the first code and this is my output
Here is the whole code I executed, I had to remove the line handle.axis2;
as it was throwing an error.( I am using matlab 2011)
close all
xMove = 3;
yMove = 10;
r = 30;
rx = -r:0.1:r;
ry = r:-0.1:-r;
[x_coor, y_coor] = meshgrid(rx, ry);
radius = sqrt(x_coor.^2+y_coor.^2);
contourf(x_coor + xMove, y_coor + yMove, radius,'edgecolor','none');
xlabel('Widht');
ylabel('Long');
axis([0 30 0 30]);
colorbar;
caxis([0 10]);
grid on;
set(gca,'layer','top');
hold on;
% X
for i = 1.5:7;
cur_x = i * 3.8;
line([cur_x, cur_x], [0 5], 'color', 'r', 'LineWidth', 1.5);
drawnow;
end;
% Y
for i = 2:7;
cur_y = i * 4;
line([0 4],[cur_y, cur_y], 'color', 'r', 'LineWidth', 1.5);
drawnow;
end;
% X2
for i = 1.5:7;
cur_x2 = i * 3.8;
line([cur_x2, cur_x2], [25 31], 'color', 'r', 'LineWidth', 1.5);
drawnow;
end;
% Y2
for i = 1:8;
cur_y2 = i * 3.5;
line([26 31],[cur_y2, cur_y2], 'color', 'r', 'LineWidth', 1.5);
drawnow;
end;
% X
line( [5.7 cur_x], [5 5], 'color', 'r', 'LineWidth', 1.5);
% Y
line( [4 4], [8 cur_y], 'color', 'r', 'LineWidth', 1.5);
% X2
line( [5.6 cur_x2], [25 25], 'color', 'r', 'LineWidth', 1.5);
% Y2
line( [26 26], [3.5 cur_y2], 'color', 'r', 'LineWidth', 1.5);
grid on;
axis([0 30 0 30]);
hold off;