Nested Axes labels and Data Plotting
조회 수: 6 (최근 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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1073460/image.jpeg)
댓글 수: 0
답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!