필터 지우기
필터 지우기

how do you make a scatter plot with categorical data with connecting lines?

조회 수: 17 (최근 30일)
Hello!
I have two 5x34 matrices that I want to compare in a plot like as follows;
My code so far is as follows:
%% dot plot
for i = 1:length(subjects)
subj=subjects{i} % individual subject
figure(1)
x = ones(1, length(lh_mean_nocap))
scatter(x, lh_mean_nocap, 'b', 'filled'); hold on
scatter(x, rh_mean_nocap, 'b', 'filled')
set(gcf, 'color', 'w');
hold on;
x = 2 * ones(1, length(lh_mean_nocap));
scatter(x, lh_mean_cap, [], [0.9100 0.4100 .1700], 'filled'); hold on
scatter(x, rh_mean_cap, [], [0.9100 0.4100 .1700], 'filled'); hold on
title('Grey White Matter Mean Signal Ratio - All Subjects');
ax = gca;
ax.XTick = [1,2];
ax.XTickLabels = {'No Cap', 'R-Net'}
ylabel('Grey White Matter Mean Signal')
xlim([0, 3])
end
Which gives me a graph with two categorical parts, however, I want to connect the corresponding categoricalvariables.
thank you!
  댓글 수: 1
dpb
dpb 2021년 11월 9일
You forgot to attach your data...
You just want a line between the means of each of the sets of scatter points, I guess? Since there's only one point shown on the sketch it's not at all clear what the data sizes are...

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

채택된 답변

Star Strider
Star Strider 2021년 11월 9일
The data being used would help produce an appropriate response.
The ‘connecting lines’ request eliminates scatter as an option because it plots only discrete points without connecting lines.
The plot function connects the markers with lines.
This works in R2021b. Posting the version/release being used for this would allow a more specific reply if this does not work correctly in the version/release being used.
x = categorical({'a','b','c','d'});
y = rand(size(x));
figure
plot(x, y, '-p')
grid
Experiment with the actual data to see if it works correctly using this approach.
.

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by