Matlab:使用x轴上的分类数据可视化数据

时间:2016-06-03 21:07:37

标签: matlab data-visualization

好的,所以我有一个包含5个'设置'的数据集(我们暂时将它们称为设置)。每个设置有3个'游戏',每个游戏有2个'级别'。在y轴上,我在某个设置中获得了游戏关卡的分数。我想在Matlab中想象这一点,但我发现很难知道我应该如何构建它。是否可以为游戏使用不同的标志(星形,圆形等),并为游戏中的两个级别中的每个级别使用不同的颜色?我知道你可以在Matlab中调整这些参数,但在这种情况下我不知道如何做到这一点。我发现很难解决这个问题,因为我希望在x轴上有分类数据,在y轴上有连续的分数刻度。我希望有人理解这一点,因为它很难解释,并且有许多明确的领域需要处理。

以下是我的数据集示例: http://i63.tinypic.com/302s1h4.png

1 个答案:

答案 0 :(得分:1)

您可以使用茎图:

%% create data matrices for each setting (could have been just a single 3-D matrix)
data1 = [3.76 3.89; 4.98 6.78; 72.0 72.8];
data2 = [4.48 5.31; 6.67 6.68; 130.2 136.5];

%% create new figure window, and set hold on to issue multiple plots to the same figure
f= figure;
hold on;

%% plot setting one in (r)ed
stem3(data1, 'r')
%% plot setting two in (b)lue
stem3(data2, 'b')

%% label the axes
xlabel('level');
ylabel('game');
zlabel('score');
%% add a legend to keep track of which color goes with which setting
legend({'setting1', 'setting2'})

%% Adding these last two settings to improve view because they are not default on some matlab versions
grid on;
view(-53, 29);  %% choose an isometric viewpoint

%% update x/y axis tick marks
ax = gca;  %% get handle to current axes
ax.XTick = [1 2];  %% for MATLAB 2014b and above
ax.YTick = [1 2 3];

%% For 2014a and earlier
%%  ax = gca;
%%  set(ax,'XTick', [1 2]);
%%  set(ax,'YTick', [1 2 3]);

enter image description here