When creating a swarmchart from categorical X and double Y values, is there a way to extract the resulting jittered X values?
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jim
el 9 de Oct. de 2024
Comentada: Adam Danz
el 10 de Oct. de 2024
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 comentarios
Respuesta aceptada
Walter Roberson
el 9 de Oct. de 2024
Editada: Walter Roberson
el 9 de Oct. de 2024
ss = struct(s);
ss.XYZJittered
Note: the default setting for swarmchart is Jitter = 'off'
Más respuestas (0)
Ver también
Categorías
Más información sobre Graphics Object Properties en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!