How to change distance of xticks in 3d bar plot (using bar3) ?

12 views (last 30 days)
Hi, I'm trying to draw multiple 3d bar plots in a single figure.
I used 'bar3', as below, but the result is quite unsatisfying.
july_mean = 20 + (50-20).*rand(24,1);
june_mean = 20 + (50-20).*rand(24,1);
may_mean = 20 + (50-20).*rand(24,1);
dat = [may_mean,june_mean,july_mean];
figure; h=bar3(dat);
I want to widen the distance between xticks 1,2,3 so that 3 barplots seem well saparated.
How can I do that?

Accepted Answer

Voss
Voss on 29 May 2022
july_mean = 20 + (50-20).*rand(24,1);
june_mean = 20 + (50-20).*rand(24,1);
may_mean = 20 + (50-20).*rand(24,1);
dat = [may_mean,june_mean,july_mean];
How about this?
figure;
h=bar3(dat);
axis square
Or this?
figure;
h=bar3(dat);
pbar = get(gca(),'PlotBoxAspectRatio')
pbar = 1×3
2.8000 25.0000 15.4508
pbar(1) = 10;
set(gca(),'PlotBoxAspectRatio',pbar)
Or maybe this?
figure;
h=bar3(dat,0.4); % bar width = 0.4
set(gca(),'PlotBoxAspectRatio',pbar)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!