【问题标题】:Matlab: visualizing data with categorical data on the x-axisMatlab:在 x 轴上使用分类数据可视化数据
【发布时间】:2016-06-03 21:07:36
【问题描述】:

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

这是我的数据集的一个示例: http://i63.tinypic.com/302s1h4.png

【问题讨论】:

  • 这个数据集有几种可能的表示形式。你能添加一个输出应该是什么样子的例子吗?你可以画出来,也可以精确解释……
  • 我想比较不同设置下游戏(关卡)的得分。因此,必须比较设置。我想看看哪种设置最适合游戏(或游戏中的关卡)。

标签: matlab data-visualization


【解决方案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]);

【讨论】:

  • 非常感谢!是否可以删除 1.5 和 2.5,因为它们不是有效选项?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-12-09
  • 2010-12-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-13
相关资源
最近更新 更多