"Baha Kuzu" <ibaha411@gmail.com> wrote in message <j3r2c9$a9u$1@newscl01ah.mathworks.com>...
> Hi everyone, I would like to define both axis of a 3d bar graph. Let's say I have a 3x5 matrix Y, and if I say bar3(Y), this locates Y values in z direction as their own values, but in x and y direction, these values are located as their index number x=1,2,3 & y=1,2,3,4,5. I can define x direction with bar3(x,Y), but what about y direction? Anybody please help?
>
> Baha
Hi,
I agree it would be nice to be able to define the data for both axes! Instead, I have resorted to the following (for a square array):
Inverse_Tick_Rate = 8;
Axes_Tick_Spacing = ceil(This_Array_Size/Inverse_Tick_Rate);
Middle_Ticks = (1+Axes_Tick_Spacing):Axes_Tick_Spacing:(This_Array_Size1);
Detector_Axes_Ticks = [1 Middle_Ticks This_Array_Size];
set(gca,'XTick',Detector_Axes_Ticks,'YTick',Detector_Axes_Ticks)
% Now reenumrate.
Old_XTickLabel = str2num(get(gca,'XTickLabel'));
New_XTickLabel = Old_XTickLabel  ceil((This_Array_Size+1)/2);
set(gca,'XTickLabel',New_XTickLabel)
Old_YTickLabel = str2num(get(gca,'YTickLabel'));
New_YTickLabel = Old_YTickLabel  ceil((This_Array_Size+1)/2);
set(gca,'YTickLabel',New_YTickLabel)
It controls the XTick/YTick locations so that your relabeling doesn't mess up when the user changes the view (3D) and Matlab would want to change the Ticks if in 'auto' mode. It always numbers the edges, and in between it labels up to 7 times, so the axes labels don't get crowded for large arrays. The offset changes the enumeration range from e.g. (1,32) to (16,15) or from (1,31) > (15,15). Hope that helps!
Adam
