Plotting different sized vectors

3 次查看(过去 30 天)
I am trying to visualize different participant data from an experiment. Participants took different amounts of time to complete the task and so the length of their time vectors is different. In the experiment, participants indicated feedback to us which we took down a timestamp of. Some participants produced 4 timestamps, some produced as much as 60. At the risk of redundancy, I am going to try to explain this thoroughly: I want to visualize this as a horizontal histogram basically where the horizontal axis is the normalized percentage of their total time and where their feedback occured with repect to their total amount of time they took to complete the task. The vertical axis is the participant number. How can I do this when some produced more data points than others?
Example:
P1: 4, 24, 130, 470, 500
P2, 3, 8, 22, 37, 59, 83, 111, 148, 209
Where the numbers are the timestamps i.e. at 4 seconds, P1 indicated feedback.
Ideally, I would like to make two figures, the first where the horizontal is a time axis that has not been normalized and showcases how some participants took longer than others and the second, described above, where the time axis has been normalized and all points are all plotted against the percentage of the whole time.
  3 个评论
Emma Walker
Emma Walker 2023-6-1
Maybe it should not be a histogram actually. Forget I said that. That is just how I was thinking about it originally. I want all the participants on the same figure.

请先登录,再进行评论。

采纳的回答

the cyclist
the cyclist 2023-6-1
编辑:the cyclist 2023-6-1
Here is one way. If you have many participants, I would generalize this a bit differently (e.g. by storing participant vectors in a cell array, using a loop). But I don't want to go too far down this path before confirming this is generally what you are looking for.
P1 = [4, 24, 130, 470, 500];
P2 = [3, 8, 22, 37, 59, 83, 111, 148, 209];
figure
hold on
plot(P1/max(P1),1,".","MarkerSize",32,"Color","black");
plot(P2/max(P2),2,".","MarkerSize",32,"Color","black");
set(gca,"YLim",[0.5 2.5],"YTick",[1 2])
  6 个评论
Emma Walker
Emma Walker 2023-6-1
编辑:Emma Walker 2023-6-1
I think you were looking at the wrong line. I have removed it for clarity.
I have run the following and have the same result
% Initialize vector
Timestamps = zeros(24,67); %Hz
fn = fieldnames(dataStruct); %datastruct contains the timestamps
fn = fn(2:end);
figure()
hold on
for i=1: numel(fn) %loop through the participants
Timestamps = 5*dataStruct.(fn{i}); %Hz
Timestamps = Timestamps(~isnan(Timestamps));
%insert plotter here:
plot(Timestamps/max(Timestamps),1,".","MarkerSize",32,"Color","black");
end
set(gca,"YLim",[0.5 numel(fn)+0.5],"YTick",1:numel(fn))
So I need to include the y-axis variation in the loop somehow - how do you do that?
Emma Walker
Emma Walker 2023-6-1
Nevermind.. I just realized my blunder. Thank you for your help!

请先登录,再进行评论。

更多回答(1 个)

Steven Lord
Steven Lord 2023-6-1
If you have an idea in your mind of roughly what you want the plot to look like, open the Plots tab of the Toolstrip and click the downward facing triangle on the right side of the Plots section of that tab. Find a thumbnail that looks close to what you're envisioning then search for the documentation for the function whose name is below the thumbnail to learn more about how to use it.

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by