フィルターのクリア

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

22 ビュー (過去 30 日間)
nines
nines 2021 年 11 月 9 日
回答済み: Star Strider 2021 年 11 月 9 日
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 Center および File ExchangeBiomedical Imaging についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by