How to compare a series of 50 values to a single value for each sample in a plot?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I want to compare a set of 50 values to a single value for each sample on a plot.
For example, for sample S1, I have 50 values and I want to show these values as a vertical line and then show where a single other value stands compared to these 50 values for S1, then do the same for the rest of the samples. So I want my x-axis to be S1, S2, S3, etc...and my y-axis to show the 50 values and the single value on top of each other or overlapping (depending on what the numerical values are). For example, for sample 1, my Y-values are:[0.6875, 0.6978, 0.7171...up to 50 values] and my x is 0.9180. I checked the available plots and also the plot gallery but couldn't find exactly what I was looking for.
Hope this makes sense, and someone can help me to create this plot.
Thanks.
댓글 수: 0
답변 (2개)
Star Strider
2017년 7월 14일
I am not certain what you want.
See if this works for you:
y = sort(rand(50,5)); % Dependent Values
x = sort(rand(1,5)); % Independent Variable
v = rand(1,5); % ‘Single Value’ To Compare
figure(1)
plot(x, y, '.b') % Plot Data As Blue Dots
hold on
plot(x, v, 'sr', 'MarkerSize',10) % Plot Comparison Value As Red Squares
hold off
댓글 수: 0
alice
2017년 7월 14일
I don't know if you have your data in structure arrays, vectors or others, but is this example similar to what you want to achieve?
% fake data generation:
data = [];
for i = 1:7
data = [data,struct('Y',10*randi(10)*rand(50),'x',randi(15))];
end
% figure generation:
figure; hold on;
for i = 1:length(data)
plot(i*ones(50,1),data(i).Y);
plot(i,data(i).x,'d');
end
set(gca,'xtick',1:length(data),'xticklabel',strcat('S',num2str((1:length(data))')));
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!