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

3 visualizaciones (últimos 30 días)
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 comentarios
Fajri
Fajri el 3 de Mzo. de 2016
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 el 17 de Jul. de 2018
hello, can you share the code you used to create this figure?
thanks in advance

Iniciar sesión para comentar.

Respuesta aceptada

Kirby Fears
Kirby Fears el 2 de Mzo. de 2016
Editada: Kirby Fears el 2 de Mzo. de 2016
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 comentarios
Fajri
Fajri el 3 de Mzo. de 2016
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 el 4 de Mzo. de 2016
Editada: Kirby Fears el 4 de Mzo. de 2016
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by