Hi there,
I am trying to plot a violin plot while also drawing boxplots for data with a 2x2 design. My data is a cell array with 3 columns in a long format, where the first column contains my dependent variable (reaction times, continuous), the second column is factor 1 and the third column is factor 2. Basically like this:
I use the following code to plot the violin plot with boxplots
figure;
g(1,1) = gramm('x', dummy_rt(:,2), 'y', dummy_rt(:,1), 'color', dummy_rt(:,3));
g(1,1).stat_violin('fill', 'transparent', 'dodge', 0.75, 'half', false);
g(1,1).stat_boxplot('width',0.2, 'notch', true, 'dodge', 0.75);
g(1,1).axe_property('Ylim', [750 3000]);
g(1,1).set_order_options('x', 0, 'color', -1);
g(1,1).set_color_options('map', 'brewer2');
g(1,1).set_title('Reaction Times for Pair Recognition (N = 48)', 'FontSize', 10);
g(1,1).set_names('x', 'Type of Pairing', 'y', 'Reaction time in ms', 'color', 'Response');
g.draw();
and get the following error:
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error in gramm/stat_boxplot>my_boxplot (line 81)
outliersy=[outliersy ysel(sel_outlier)'];
Error in gramm/stat_boxplot>@(dobj,dd)my_boxplot(dobj,dd,p.Results) (line 24)
obj.geom=vertcat(obj.geom,{@(dobj,dd)my_boxplot(dobj,dd,p.Results)});
Error in gramm/draw (line 548)
obj.geom{geom_ind}(obj,draw_data);
The results look like this:
Curiously, I used the same code to successfully produce a plot before. The only thing I changed for the data in this example are the values of the dependent variable. It worked with accuracy values, but does not work with reaction times anymore. It looks like this:
I checked the arrays in both cases, and the format and dimensions are the same. Even the factor levels are the same. So something is not working with the boxplot and the 'color'argument.
I'd appreciate any help on this!