Borrar filtros
Borrar filtros

A Problem with bar3 Function

4 visualizaciones (últimos 30 días)
may
may el 11 de Oct. de 2013
Comentada: may el 11 de Oct. de 2013
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 comentarios
David Sanchez
David Sanchez el 11 de Oct. de 2013
It seems your Y-axis already shows those values. Could you please paste the code?
may
may el 11 de Oct. de 2013
Editada: may el 11 de Oct. de 2013
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

Iniciar sesión para comentar.

Respuestas (1)

A Jenkins
A Jenkins el 11 de Oct. de 2013
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 comentario
may
may el 11 de Oct. de 2013
Editada: may el 15 de Oct. de 2013
Thanks. Since the number of grids is around 10 in some cases using subplot, the figures are not clear.

Iniciar sesión para comentar.

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by