matlab绘制三组xy的分组式水平直方图代码
时间: 2023-03-27 21:03:54 浏览: 85
以下是 Matlab 绘制三组 xy 的分组式水平直方图的代码:
```matlab
x1 = [1 2 3 4 5];
y1 = [2 4 6 8 10];
x2 = [1 2 3 4 5];
y2 = [3 6 9 12 15];
x3 = [1 2 3 4 5];
y3 = [4 8 12 16 20];
figure;
hold on;
barh(x1, y1, 'r');
barh(x2, y2, 'g');
barh(x3, y3, 'b');
set(gca, 'YDir', 'reverse');
xlabel('Value');
ylabel('Group');
legend('Group 1', 'Group 2', 'Group 3');
```
希望对你有所帮助!
相关问题
matlab绘制三组xy的累积式直方图代码
以下是 Matlab 绘制三组 xy 的累积式直方图的代码:
x1 = randn(100,1);
y1 = randn(100,1);
x2 = randn(100,1)+2;
y2 = randn(100,1)+2;
x3 = randn(100,1)-2;
y3 = randn(100,1)-2;
figure;
hold on;
histogram2(x1,y1,'DisplayStyle','stairs','Normalization','cdf','LineWidth',2);
histogram2(x2,y2,'DisplayStyle','stairs','Normalization','cdf','LineWidth',2);
histogram2(x3,y3,'DisplayStyle','stairs','Normalization','cdf','LineWidth',2);
xlabel('X');
ylabel('Y');
legend('Group 1','Group 2','Group 3');
title('Cumulative Histogram of Three Groups of XY Data');
matlab绘制三组xy的三维列式水平直方图代码
以下是绘制三组xy的三维列式水平直方图的 MATLAB 代码:
```matlab
% 生成数据
x = [1 2 3 4 5];
y = [1 2 3];
z1 = [1 2 3; 4 5 6; 7 8 9; 10 11 12; 13 14 15];
z2 = [15 14 13; 12 11 10; 9 8 7; 6 5 4; 3 2 1];
z3 = [1 3 5; 7 9 11; 13 15 17; 19 21 23; 25 27 29];
% 绘制图形
figure;
bar3h(x, z1, y, 'hist');
hold on;
bar3h(x, z2, y, 'hist');
bar3h(x, z3, y, 'hist');
xlabel('X');
ylabel('Y');
zlabel('Z');
title('三组xy的三维列式水平直方图');
```
希望能对您有所帮助!
阅读全文