Nested Axes labels and Data Plotting

조회 수: 6 (최근 30일)
Michael Shagam
Michael Shagam 2022년 7월 21일
답변: Sayan 2023년 8월 30일
Does anyone know any tricks for doing nested catagorical grouping of plotted data? In the example below of a swarmchart(), I would like to group the categorical names on the x-axis by Group A, B , C, etc.
It would be nice if matlab had a general grouping or stacking function of arbitrary plotted data from tables. In excel, you can easily nest plotted tabular data with pivot table plots like this example. And jmp makes it very easy to group axes or entire plots with thegraph builder. Is anyone aware of built-in functions or tips to achieve my desire?

답변 (1개)

Sayan
Sayan 2023년 8월 30일
My understanding of the question is that multiple categories in a table need to be merged into one category. In MATLAB categories can be merged with "margecats" function. Here is an example of how this can be done.
T = table([1; 2; 3;4;5], {'A'; 'B'; 'C';'D';'E'}, 'VariableNames', {'NumericColumn', 'CategoricalColumn'});
T.CategoricalColumn = categorical(T.CategoricalColumn);
T.CategoricalColumn = mergecats(T.CategoricalColumn, {'A', 'B','C'}, 'ABC');
%% Use the plot function to plot the data with the merged categories column
Further information can be found in the following MATLAB documentation: https://www.mathworks.com/help/releases/R2021a/matlab/ref/categorical.mergecats.html
Hope this helps resolve the query.

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by