Scatter Plot with nan values

9 visualizzazioni (ultimi 30 giorni)
AB
AB il 23 Ago 2016
Risposto: Walter Roberson il 23 Ago 2016
Hi
I have 3 groups, say A, B and C in separate arrays of dimensions say 20 by 1, 30 by 1 and 50 by 1 respectively. I want to plot a scatter plot of these values with a line indicating the mean. How can this be done. When I join A,B and C to fill up empty spaces by nan values, i am unable to get the scatter plot. Any simple code to plot the scatter plot and mean?

Risposte (1)

Walter Roberson
Walter Roberson il 23 Ago 2016
You cannot scatter plot those. scatter plot requires 2 dimensions, but you only have one dimension.
Perhaps you want something like
hA = scatter( 1 * ones(length(A),1), A);
hold on
hB = scatter( 2 * ones(length(B),1), B);
hC = scatter( 3 * ones(length(C),1), C);
m = mean([A; B; C]);
hm = line([1 3], [m m])
legend([hA, hB, hC, hm], {'A', 'B', 'C', 'mean'});
Or perhaps you just want to use boxplot()

Categorie

Scopri di più su Data Distribution Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by