![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/277527/image.png)
Plot graphic with 3 variables
1 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I want to plot a graphic with my data that is grouped by categories: level (0.03, 0.05 or 0.08) and 1/0 (category 1 or 0).
I want to plot time as a function of level (3 levels), split by category 1 and category 0, as shown in the drawing that i sketched.
How can I do it in matlab?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/277522/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/277523/image.png)
0 个评论
采纳的回答
Ameer Hamza
2020-3-16
编辑:Ameer Hamza
2020-3-16
Following code shows the example to extract data and plot in on the axes
A = [1 0.03 0.51;
1 0.05 0.42;
1 0.08 0.45;
0 0.03 0.57;
0 0.05 0.47;
0 0.08 0.60];
split_matrix = splitapply(@(x) {x}, A(:,2:3), A(:,1)+1);
ax = axes();
hold(ax);
for i=1:numel(split_matrix)
plot(ax, split_matrix{i}(:,1), split_matrix{i}(:,2), '.-', 'MarkerSize', 50, 'LineWidth', 2)
end
xlabel('Level');
ylabel('Time (s)');
xlim([0.03 0.08])
ylim([0.2 0.6]);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/277527/image.png)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!