Skip to content

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

Description

@kibs-dtu

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;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions