Hi Nethravathi,
To combine multiple 3D bar graphs into a single figure, you can use the bar3 function and manipulate the positions of each set of bars to ensure they don't overlap.
The below code snippet demonstrates how to achieve this, using dummy data:
% Number of datasets
numDatasets = 4;
% Dimensions of each dataset
numRows = 24;
numCols = 13;
% Generate random data for each dataset
data = cell(1, numDatasets);
for i = 1:numDatasets
data{i} = rand(numRows, numCols); % Replace this with your actual data
end
% Create a new figure
figure;
hold on; % This allows multiple plots in the same figure
% Define an offset for each dataset to prevent overlap
offset = 2; % Adjust this value to change the spacing between datasets
% Plot each dataset using bar3
for i = 1:numDatasets
% Adjust the x-position of each dataset
xOffset = (i - 1) * (numCols + offset);
% Plot the 3D bar graph with an offset
bar3(data{i}, 'stacked');
% Adjust the XData to offset the bars
h = get(gca, 'Children');
for j = 1:length(h)
xData = get(h(j), 'XData');
set(h(j), 'XData', xData + xOffset);
end
end
% Set axis labels
xlabel('Category');
ylabel('Group');
zlabel('Value');
% Set title
title('Combined 3D Bar Graph');
% Adjust viewing angle for better visualization
view(-30, 30);
% Release the hold on the current figure
hold off;
For more details, please refer to the following MathWorks documentation: bar3 - https://www.mathworks.com/help/matlab/ref/bar3.html
Hope this helps!