Filter löschen
Filter löschen

How to compare a series of 50 values to a single value for each sample in a plot?

1 Ansicht (letzte 30 Tage)
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.

Antworten (2)

Star Strider
Star Strider am 14 Jul. 2017
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

alice
alice am 14 Jul. 2017
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))')));

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by