Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several violins - how do I force the order along the horizontal axis? #74

Open
kibs-dtu opened this issue Jul 29, 2024 · 1 comment
Open

Comments

@kibs-dtu
Copy link

I want to make a violin-plot showing six distributions of data, and I also want the data to be in the order that I enter it to Matlab.
I give an order "1-2-3-4-5-6" and Matlab plots it in the order "2-1-5-4-3-6".
How do I fix that?

Thanks, Kirstine

==

Matlab code:

data = [T1_inside_cells_noIR;T1_2hDMSO_inside_noIR;T1_cellsurface_noIR;T1_2hDMSO_surface_noIR;T1_inside_cells_wIR;T1_cellsurface_wIR];
str1 = strings(size(T1_inside_cells_noIR));
str2 = strings(size(T1_2hDMSO_inside_noIR));
str3 = strings(size(T1_cellsurface_noIR));
str4 = strings(size(T1_2hDMSO_surface_noIR));
str5 = strings(size(T1_inside_cells_wIR));
str6 = strings(size(T1_cellsurface_wIR));

str1(:,1) = 'C, no IR';
str2(:,1) = 'C, 2h DMSO';
str3(:,1) = 'M, no IR';
str4(:,1) = 'M, 2h DMSO';
str5(:,1) = 'C, w CW NIR';
str6(:,1) = 'M, w CW NIR';
strcat = [str1; str2; str3; str4; str5; str6];

newcolors = [1 0.0 0.0
0.6 0.0 0.70
0.1 0.9 0.00
0.0 0.0 1.
0.989 0.813 0.19
0.0 0.7 0.8];

figure(); hold on;
v3 = violinplot(data,strcat,'ViolinColor',newcolors);
ylabel('\it{T_1} \rm{in microseconds}');
ylim([100,390]);
hold off;

@bastibe
Copy link
Owner

bastibe commented Aug 6, 2024

You can always plot each violin separately

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants