필터 지우기
필터 지우기

how can I plot single x-value of type string against multiple y-values of type double?

조회 수: 4 (최근 30일)
Good evening!
How can I plot string-type x-value against multiple double-type y-values?
I want to plot a 2D-point diagramm of number of repetitions (string data for x-axis, for example '40 repetitions') against result datas (double for y-axis, for example 0.55, 0.66, 0.57, 0.67 ...). Number of results correspond to the number of repetitions.
It looks like this:
'40 repetitions' [0.55 0.66 0.57 0.67 ...] ; --> 40 result datas
'10 repetitions' [0.67 0.78 0.65 ...] ; --> 10 result datas
'4 repetitions' [0.86 0.65 ...] ; --> 4 results datas
and so on. So that in the end we see the scattering of result points for each of repetition scheme.
Thank You!
Edit:
I've tried with plot and this is how I want to present the result datas. But instead of "1", "2", and "3" itu should be "40 repetitions", "10 repetitions", "4 repetitions" and so on...
  댓글 수: 3
Fajri
Fajri 2016년 3월 3일
thank you Kirby!
I've managed to set all the results as black-filled circles and the arithmetical mean for each repetition as red-filled circles.
I have one more questions though: How can I display Legend that says the black circles as "results value" and the red circles as "mean value"?
I very appreciate your help :)
José Mauro Vargas Hernández
José Mauro Vargas Hernández 2018년 7월 17일
hello, can you share the code you used to create this figure?
thanks in advance

댓글을 달려면 로그인하십시오.

채택된 답변

Kirby Fears
Kirby Fears 2016년 3월 2일
편집: Kirby Fears 2016년 3월 2일
You could visualize the data in many ways. Here's a simple way scatter the data and label each series.
% using random data
data = {rand(1,40),rand(1,10),rand(1,4)};
dataLabels = {'40 reps','10 reps','4 reps'};
% plotting scatter plot
hold on;
for i = 1:numel(data),
scatter(repmat(i,1,length(data{i})),data{i},'*');
end
hold off;
ax = gca;
ax.XTick = 1:numel(dataLabels);
ax.XTickLabel = dataLabels;
ax.XLim = [0 numel(dataLabels)+1];
  댓글 수: 3
Fajri
Fajri 2016년 3월 3일
thank you Kirby!
I've managed to set all the results as black-filled circles and the arithmetical mean for each repetition as red-filled circles.
I have one more questions though: How can I display Legend that says the black circles as "results value" and the red circles as "mean value"?
I very appreciate your help :)
Kirby Fears
Kirby Fears 2016년 3월 4일
편집: Kirby Fears 2016년 3월 4일
I'm glad that worked for you, Fajri.
As you stated, you're now plotting two kinds of things in one chart: the "results values" and "mean values".
The legend() command in Matlab allows you to name each series in the order in which they were plotted. So the easiest way to make the legend you're looking for is to plot a "results value" and a "mean value" as the first two calls to scatter. Then you can call legend() with two names to display.
Expanding on my example above, you can achieve this by scattering the "results value" and "mean value" one after the other inside the for-loop.
% plotting scatter plot
hold on;
for i = 1:numel(data),
scatter(repmat(i,1,length(data{i})),data{i},'*');
scatter(i,mean(data{i}),'*');
end
hold off;
legend({'all values','mean value'});
I'll leave the marker color choices to you.
Hope this helps.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by