将 bar3 地块分组为 bar [英] Grouping bar3 plots like bar

查看:52
本文介绍了将 bar3 地块分组为 bar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能将 bar 图的相同分组行为放入 bar3.例如,如果你绘制

I'm wondering if it is possible to get the same grouping behavior of bar plots into bar3. For example, if you plot

  bar(rand(3));

每个点你得到 3 个小节;bar 将每个 x 的不同 y 值分组.现在我想对 3D 数据做同样的事情.也就是说,我有几个二维数据切片,我想将它们可视化为条形组.那么,如果我的数据是

you get 3 bars for each point; bar groups the different y values for each x. Now I would like to do the same with a 3D data. That is that I have several slices of 2D data that I want to visualize as groups of bars. Then, if my data is

data = rand(3,3,2);

我想将 data(1,1,:) 视为一组条形,将 data(1,2,:) 视为另一组,等等

I would like to see data(1,1,:) as a group of bars, and data(1,2,:) as another group and so on.

有可能吗?我找不到实现这一目标的方法.

Is it possible? I cannot find a way of achieving this.

我正在添加更多细节,以便更好地解释.

I'm adding more details, to explain it better.

假设我们有两组或更多组数据{x_(i,j)^s}.我需要的是在相同的网格位置分组(i,j),所有集合s.在这个问题中,他们将数据集并排分组,而不是元素-明智的,像这样:

Lets said that we have two, or more, sets of data {x_(i,j)^s}. What I need is to group in the same grid position (i,j), all the sets s. In this question, they are grouping the data sets side by side, not element-wise, like this:

x1(s1) x1(s2) x1(s3)   x2(s1) x2(s2) x2(s3)   x3(s1) x3(s2) x3(s3)
x4(s1) x4(s2) x4(s3)   x5(s1) x5(s2) x5(s3)   x6(s1) x6(s2) x6(s3)
x7(s1) x7(s2) x7(s3)   x8(s1) x8(s2) x8(s3)   x9(s1) x9(s2) x9(s3)

我想要 bar 命令的行为,当放置多个数据集时它倾向于分组.我想知道是否有可能.

I would like the bar command behavior, it tends to group when putting more than one data set. I would like to know if it is possible.

推荐答案

我不确定我是否完全理解,但是如果你正在寻找像你提到的 bar(rand(3)) 那你可以试试

I am not sure I fully understood, but if you are looking for grouped behavior like you mention with bar(rand(3)) then you can try

figure; bar3(rand(5),'grouped');
% or maybe
figure; bar3(rand(5),'stacked');

或尝试重新排列 data 中的数据,以便它可以更好地与带有 reshape 的 bar3 配合使用:

or try to rearrange the data in data so it can work better with bar3 with reshape:

data = rand(3,3,2);
% now each data(i, j, :) will be in single row 
changeddata = reshape(data , [size(data , 1)*size(data , 2) 2]);
figure; bar3(changeddata);
figure; bar3(changeddata ,'grouped');
figure; bar3(changeddata ,'stacked');

也许如果您能给出一个代码示例,说明它在一组中的外观,将有助于更好地理解您的问题.

Maybe if you can give a code example for how it's supposed to look in one group, it would help to understand your question better.

这篇关于将 bar3 地块分组为 bar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆