How to creat grouped violin plot?

조회 수: 47 (최근 30일)
xu yichen
xu yichen 2023년 5월 8일
답변: Adam Danz 2024년 10월 9일
Hi, how can I create a grouped violin plot like this? I have tried different violin plot function such as GitHub - bastibe/Violinplot-Matlab: Violin Plots for Matlab. But I cannot find a way to create violin plot that is grouped by their categoery. The example figure is created in Seaborn-python. But I am not very familiar with python so I can only create the figure with default setting. It will be great if somebody can help me to create it in Matlab! :)

답변 (3개)

Abhinaya Kennedy
Abhinaya Kennedy 2024년 6월 14일
편집: Abhinaya Kennedy 2024년 6월 14일
I found this on MATLAB File Exchange: https://www.mathworks.com/matlabcentral/fileexchange/45134-violin-plot. It does pretty much what your image depicts. Hope it helps.

Jeremy Z
Jeremy Z 2024년 7월 30일
I know this answer might be slightly late but I recently found a good alternative on MATLAB File Exchange: https://www.mathworks.com/matlabcentral/fileexchange/136524-daviolinplot-beautiful-violin-and-raincloud-plots . This can create grouped violin plot in a nice way.

Adam Danz
Adam Danz 2024년 10월 9일
MATLAB R2024b introduces a new violinplot with a grouping option.
data = random(makedist('Weibull'),1000,8);
xgroup = categorical(["Post 1m", "Post 6m"]);
colorGroup = categorical(["med off rest","med off walk", ...
"med on rest", "med on walk"]);
xgroupData = repelem(xgroup,height(data),4);
cgroupData = repmat(colorGroup,height(data),2);
violinplot(xgroupData(:), data(:), GroupByColor=cgroupData(:))
legend(colorGroup)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by