필터 지우기
필터 지우기

How to plot different datasets in a scatterplot next to each other at discrete points on x-axis?

조회 수: 9 (최근 30일)
Hello,
I have 3 datasets that were obtained at positions 1-10 and have values.
The positions in the table are Strings, i.e. '1', '2', and each dataset contains values for each position.
Now I want to plot the data from all three datasets for each position next to each other in the same (scatter?) plot.
This is what I roughly want it to look like, excuse the crude image. I think I found a picture of what I want it to look like before, but I can't find it anymore.
The dots at each point should be evenly spaced out in the x-axis and there should be enoughenough spacing between the individual points 1-10 in the x-axis.
How can I achieve this? I tried using the reguar scatterplot, but that puts the dots on a line which makes it hard to read:
I pick the datapoints I want to plot from each dataset through an array of strings:
plotPositionDataset1 = [string(1:10)];
plotPositionDataset2 = [string(1:10)];
plotPositionDataset3 = [string(1:10)];
To map the strings I want to plot with the ones in my table I used categorical:
scatterPlotdataX = categorical(Table_Data_1.Position,plotPositionDataset1);
scatterPlotdataY = Table_Data_1.values;
scatter(scatterPlotdataX,scatterPlotdataY,20,"red","o","LineWidth",0.7,"DisplayName","Test1");
Then I repeat the process for all three, which results in the second from figure above.
How can I create a plot that looks like the first figure above? I looked at swarm plots, but that isn't exactly what I want.

답변 (1개)

Star Strider
Star Strider 2024년 1월 15일
See if the swarmchart function (introduced in R2020b) will do what you want.
  댓글 수: 6
Daniel Neyers
Daniel Neyers 2024년 1월 15일
Thank you for your effort. Not sure if I should mark this as solved.
For now I ended up using the regular scatter plot with 3 different symbols and colours. It is somewhat readable and good for now.

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

카테고리

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

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by