필터 지우기
필터 지우기

A Problem with bar3 Function

조회 수: 4 (최근 30일)
may
may 2013년 10월 11일
댓글: may 2013년 10월 11일
I used bar3 function to generate the following figure, but I do not know how to set Y label correctly in my code. In each grid, Y label should be 0.3,0.4,0.5,0.6,0.7,0.8. The code that I use is in the commitment below. I would appreciate if you could help me. Thanks.
  댓글 수: 2
David Sanchez
David Sanchez 2013년 10월 11일
It seems your Y-axis already shows those values. Could you please paste the code?
may
may 2013년 10월 11일
편집: may 2013년 10월 11일
Here is the code I use, I really do not understand where the problem is. I would appreciate if you could help me.
function Plot_4D_bar(Z,grid_cell,x_cell,y_cell,xlab,ylab,zlab)
%grid_cell is the names of the grids here it is grid_cell={'grid1','grid2','grid3'}
%y_cell is obtained in the following way
%y=[0.3,0.4,0.5,0.6,0.7,0.8]; y_cell=num2cell(y);
%num_grid is number of grids
num_grid=size(grid_cell,2);
%length_grid is the length of the grids
length_grid=size(Z,1)/num_grid;
Y=1:size(Z,1)+num_grid-1;
Y(find(mod(Y,length_grid+1)==0))=[];
bar3(Y,Z)
view(-70,30)
a=2;
for i=1:size(grid_cell,2)
text(-2,a,grid_cell{1,i});
a=length_grid+1+a;
end
set(gca,'YTickLabel',y_cell);
set(gca,'XTickLabel',x_cell);
xlabel(xlab);
ylabel(ylab);
zlabel(zlab);
end

댓글을 달려면 로그인하십시오.

답변 (1개)

A Jenkins
A Jenkins 2013년 10월 11일
Are you trying to make 3 independent graphs on the same figure?
Are you familiar with subplot()? That would give you more control over the separate axes.
subplot(1,3,1)
bar3(y,ones(size(y)))
view(-70,30)
ylabel('grid 1')
subplot(1,3,2)
bar3(y,1:1:6)
view(-70,30)
ylabel('grid 2')
subplot(1,3,3)
bar3(y,6:-1:1)
view(-70,30)
ylabel('grid 3')
  댓글 수: 1
may
may 2013년 10월 11일
편집: may 2013년 10월 15일
Thanks. Since the number of grids is around 10 in some cases using subplot, the figures are not clear.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by