Finding a way to cleanly show double data points in a plot

3 次查看(过去 30 天)
I want to make a residual plot like this one.
Matlabs plots dont show double data points in any way though, how can i fiks this?
right now i have created this plot by holding on and creating difrent plots with the same x value btw.

回答(2 个)

crijn
crijn 2023-10-3
never mind, i found the function that works for this problem, it is called swarmchart.
just use a second plot for drawing a line and i can get the same graph as i showed in the first picture :)

John D'Errico
John D'Errico 2023-10-3
编辑:John D'Errico 2023-10-3
You want to show two different points at different locations on the x axis. But currently you have them with the same values for x.
The answer is simple. You need to adjust the x coordinates the duplicate points will be plotted at. Yes, I know that you want MATLAB to know what you want it to do. But it cannot read your mind, and if MATLAB decided to plot points at locations other than where they were specified, then I am sure someone would start to scream about a bug, accompanied by a great deal of wailing and gnashing of teeth.
But you do not need this by hand. Simply search for duplicate points. You can use tools like diff and find to identify exact duplicates, although you may want to use a tolerance to identify them. Then just add and subtract some small number from each x value. Again, that is easily automated.
  1 个评论
crijn
crijn 2023-10-3
Ah so there is no way in the matlab systems were this is can be done directly.
Is there than a way to find those duble data point in my matrix of data and automaticly give it a difrent x value manualy with code?
for refrence, this is the code i use to make the plots:
aantal_treat = size(data,2);
aantal_rep = size(data,1);
figure(3);
for i = 1:aantal_treat;
resudal(:,i) = data(:,i)-mean(data(:,i))
x_as = ones(aantal_rep).*x_waarde(i);
plot(x_as,resudal(:,i),'.-','MarkerSize',20);
hold on
end
plot(x_waarde,zeros(1,size(data,2)),'.-', 'Color', [0.5, 0.5, 0.5]) % x-as
hold off;
I think for my code that I want the duoble points in resudal(:,i) to be found in as index. But i have not found any good system online how would you solve this?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by