我在MATLAB中有一个矩阵(4,100)。其列中的每一列都是这样的:第一元素矩阵(1,i)越小,第四元素矩阵(4,i)越大。就像
matrix(:,1)= - 0.3; 0,4; 0,4; 0,9我怎样才能做一个条形图?两条边??
每栏必须以栏为单位表示,以便在最后制作100栏。
感谢
解决方案我不确定这是否是您想要的,但您可以绘制所有不同颜色的酒吧,从最大(最后一行矩阵)到最小的(矩阵的第一行),以便更小的堆积过来,但让更大的看到:
matrix = [.1.2 .3 .4 .5 .2 .3 .5 .6 .7 .4 .8 .7 .8 .5 .6 .9 .8 .9 .9]; %//示例数据持有颜色= {'r','g','b','c'}; %//定义颜色对于n = size(矩阵,1): - 1:1%//遍历行,从最后到第一个 bar(matrix(n,:),colors {n }) end
I have a matrix(4,100) in MATLAB. Each one of its column are in such way that the 1st element matrix(1,i) is the smaller and the 4th element matrix(4,i) is the bigger. Something like
matrix(:,1) = - 0.3; 0,4; 0,4; 0,9How can I do a bar graph were I can plot as a bar the distance between the two edges?
each column has to be represented by on bar in order to make 100 bars at the end.
Thanks
解决方案I'm not sure if this is what you want, but you can plot all bars in different colors, from the largest (last row of matrix) to the smallest (first row of matrix), so that the smaller ones get stacked over but let the larger ones to be seen:
matrix = [.1 .2 .3 .4 .5 .2 .3 .5 .6 .7 .4 .4 .8 .7 .8 .5 .6 .9 .8 .9]; %// example data hold on colors = {'r','g','b','c'}; %// define colors for n = size(matrix,1):-1:1 %// iterate over rows, from last to first bar(matrix(n,:), colors{n}) end更多推荐
在MATLAB中绘制条形图
发布评论