How to plot multiple data sets on bar3

10 ビュー (過去 30 日間)
Kristine
Kristine 約4時間 前
編集済み: Kristine 約2時間 前

I’m trying to make multiple 3D histogram plots side-by-side. I think I need to use the bar3 function, but I don’t know what combination of code to use. Am I trying to make something that doesn’t exist in MATLAB?

  2 件のコメント
dpb
dpb 12分 前
Can you sketch what you envision this should look like or show a published example?
bar3 is quite limited in its flexibility to modify and there are no other builtin functions with additional abilities beyond it.
Kristine
Kristine 2分 前
I hope this image is a good enough representation of that I meant. I'm not very good at 3D drawing.
x-axis and z-axis make a normal histogram, but then you have multiple sets along the y-axis.

サインインしてコメントする。

回答 (1 件)

dpb
dpb 41分 前
移動済み: dpb 41分 前
Oh. That is what bar3 can/does do. Look at the examples; the Z data array would be 3x3 with the x-axis being rows and y the columns.
Z=[1 2 1; 3 3 2; 3 2 3].'; % counts that approximate sketch
hB=bar3(Z); % make base 3D bar
map=[0 0 1; 1 0 0; 0 1 0]; % set colormap to match sketch b,r,g
colormap(map)
  1 件のコメント
Kristine
Kristine 24分 前
編集済み: Kristine 23分 前
I tried something similar and it didn't work (shown below). I am also working with a pretty large data set and I want those area to be histograms for that reason, so I can bin the data. I'm also not sure I have the same number of data for each set.
When I ran your code with my data set the image shown is what I got.
A = Data.1;
B = Data.2;
C = Data.3;
D = Data.4;
E = [A; B; C; D];
bar3(E)

サインインしてコメントする。

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by