When creating a swarmchart from categorical X and double Y values, is there a way to extract the resulting jittered X values?
14 ビュー (過去 30 日間)
古いコメントを表示
s = random_swarms(2^10);
jitteredXvals = [] % WHAT GOES HERE?
function [s, x, y] = random_swarms(n)
% Input:
% n: number of data points
% Outputs:
% s: handle to the swarmchart
% x: categorical variable ('A' or 'B')
% y: random numbers
% Generate random categorized values
categories = {'A', 'B'};
x = categorical(categories(randi(2, n, 1)));
y = randn(n, 1);
% Create swarmchart
s = swarmchart(x, y);
% Set title and labels
title('Random Swarmchart')
xlabel('Category')
ylabel('Random Value')
end
5 件のコメント
採用された回答
Walter Roberson
2024 年 10 月 9 日
編集済み: Walter Roberson
2024 年 10 月 9 日
ss = struct(s);
ss.XYZJittered
Note: the default setting for swarmchart is Jitter = 'off'
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graphics Object Properties についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!