Altering axes in subplot
4 views (last 30 days)
Show older comments
I have a matrix whose values change with each iteration, and this matrix I plot. A minimal example is the following
figure(1)
a=ones(11, 11);
for i=1:20
a(2, 3) = 1+a(2, 3);
a(1, 4) = 1+a(1, 4);
subplot(1,2,1), imagesc(a)
subplot(1,2,2), imagesc(a)
pause(0.1)
end
I would like to do the following:
1. On the plot to the left (they are identical only in this example..) I would like the x-axis to start at 0. If i use `xlim([0 11])` the first column (belonging to 0) is just white. Is there a way to circumvent this?
2. I would like for the left y-axis to run from `-5..5`.
Is there a way to achieve this? Thanks in advance.
1 Comment
Jan
on 5 Jan 2014
The question is not clear yet. What do you want to appear instead of the white column? What about ylim([-5 5])?
Accepted Answer
per isakson
on 6 Jan 2014
Try this:
function test()
figure(1)
a = zeros(11,11)+32;
a([1,1,11,11],[1,11,1,11]) = 1;
ax1 = subplot(1,2,1);
ax2 = subplot(1,2,2);
for i=1:20
a(1, 1) = 1+a(1, 1);
a(1,11) = 2+a(1,11);
a(11,1) = 3+a(11,1);
a(11,11)= 1+a(11,11);
image( a, 'Parent', ax1 )
image( a, 'Parent', ax2 )
set( ax1, 'XLim', [ 0.5, 11.5 ] )
set( ax1, 'YLim', [ 0.5, 11.5 ] )
set( ax2, 'XLim', [ 0.5, 11.5 ] )
set( ax2, 'YLim', [ 0.5, 11.5 ] )
pause( 0.1 )
end
end
0 Comments
More Answers (0)
See Also
Categories
Find more on Subplots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!