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 Center および File ExchangeSubplots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by