Scatter Plot with nan values

9 次查看(过去 30 天)
AB
AB 2016-8-23
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?

回答(1 个)

Walter Roberson
Walter Roberson 2016-8-23
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()

类别

Help CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by