I have a 2d matrix called myval. Its size is 21x11.
What I want to do is plot only the first 11 rows and all columns ie 11x11. So I use a bar3 function in matlab to do this which gives me a good plot.
Now the z axis is the actual value stored in myval
matrix. But it so happens that I want the x and y axis values (which represent the corresponding row and column) to start at 0 instead. That is value of (1,1) will be (0,0) and value at (1,2) will be (0,1). I do not want to change the actual value in the myval
matrix. I just want to shift the axis. this is my actual code
bar3(myval(1:t,:));
xlim([0 p]);
ylim([0 t]);
zlim([0 1);
set(gca,'fontsize',16);
set(gca,'XTick',(0:2:p));
set(gca,'YTick',0:2:t);
set(gca,'ZTick',0:1);
You need to give bar3
both an x and Y input then the columns will appear where you want them.
x = 0:10;
Y = myval(1:t,:);
bar3(x,Y)
Or, to controll both the x and y axis, you can use:
x = 0:10;
bar3(Y)
set(gca,'YTickLabel', x)
set(gca,'XTickLabel', x)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.