How to Switch order of Boc plots (2024)

10 views (last 30 days)

Show older comments

Ayan on 26 Jun 2023

  • Link

    Direct link to this question

    https://matlabcentral.mathworks.com/matlabcentral/answers/1988233-how-to-switch-order-of-boc-plots

  • Link

    Direct link to this question

    https://matlabcentral.mathworks.com/matlabcentral/answers/1988233-how-to-switch-order-of-boc-plots

Commented: Voss on 15 Aug 2023

Open in MATLAB Online

The Code I have is attached I would like to switch the placements of Adaptive and No Tag

load('comedyworkspace.mat')

% Color Set

color_grey = [0.55,0.55,0.55];

green.fill = 1.08*[195,214,155]/255;

green.light = 0.9*[195,214,155]/255;

green.dark = 0.7*[195,214,155]/255;

purple.fill = 1.08*[179,162,199]/255;

purple.light = 0.9*[179,162,199]/255;

purple.dark = 0.7*[179,162,199]/255;

orange.fill = 1.06*[239,111,68]/255;

orange.light = 0.9*[239,111,68]/255;

orange.dark = 0.7*[239,111,68]/255;

blue.fill = 1.12*[142,180,227]/255;

blue.light = 0.9*[142,180,227]/255;

blue.med = 0.7*[142,180,227]/255;

blue.dark = 0.5*[142,180,227]/255;

red.dark = [153,0,0]/255;

red.fill = [255,102,102]/255;

%% Prep axes

figure

subplot(2,2,1)

hold on; grid on;

set(gca, 'YGrid', 'on', 'XGrid', 'off')

s1=Competence{1:15, 1};

s2=Competence{1:15, 2};

s3=Competence{1:15, 3};

%s5=mean(s1);

%s6=mean(s2);

%s7=mean(s3);

ColorOrder=[red.dark;blue.light;green.dark;purple.dark];

line_width=1.0;

b = boxchart(ones(1, length(s1)), s1);

set(b, 'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 1), ...

'BoxFaceColor', ColorOrder(:, 1))%,...

%'MarkerEdgeColor', green.dark);

set(findobj(gcf,'-regexp','Tag','\w*Whisker'),'LineStyle','-')

median = findobj(gcf, 'type', 'line', 'Tag', 'Median');

set(median, 'Color', color_grey, 'LineWidth', line_width);

boxchart(ones(1, length(s1)), s1, ...

'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 1), ...

'BoxFaceColor', ColorOrder(:, 1));

boxchart(2 * ones(1, length(s2)), s2, ...

'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 2), ...

'BoxFaceColor', ColorOrder(:, 2));

boxchart(3 * ones(1, length(s3)), s3, ...

'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 3), ...

'BoxFaceColor', ColorOrder(:, 3));

%'MarkerEdgeColor', green.dark);

set(findobj(gcf,'-regexp','Tag','\w*Whisker'),'LineStyle','-')

median = findobj(gcf, 'type', 'line', 'Tag', 'Median');

set(median, 'Color', color_grey, 'LineWidth', line_width);

hold on

%% Final axes labels and options

title('Competence');

xticks(1:3)

xticklabels({'Adaptive', 'Hardcoded', 'No Tag'})

xtickangle(45)

ylim([0 9])

yticklabels({'1', '2', '3', '4', '5', '6', '7','8','9'})

ylabel('Rating')

% yline(1,'color',color_grey,'LineWidth',1);

hold on

scatter(1,mean(Competence{2:15,2}),"+")

scatter(2,mean(Competence{2:16,2}),"+")

scatter(3,mean(Competence{2:15,2}),"+")

% plot([s5 s6 s7 ], 'db');

hold off

hold on

subplot(2,2,2)

hold on; grid on;

set(gca, 'YGrid', 'on', 'XGrid', 'off')

s1=Warmth{1:15, 1};

s2=Warmth{1:15, 2};

s3=Warmth{1:15, 3};

%s5=mean(s1);

%s6=mean(s2);

%s7=mean(s3);

ColorOrder=[red.dark;blue.light;green.dark;purple.dark];

line_width=1.0;

b = boxchart(ones(1, length(s1)), s1);

set(b, 'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 1), ...

'BoxFaceColor', ColorOrder(:, 1))%,...

%'MarkerEdgeColor', green.dark);

set(findobj(gcf,'-regexp','Tag','\w*Whisker'),'LineStyle','-')

median = findobj(gcf, 'type', 'line', 'Tag', 'Median');

set(median, 'Color', color_grey, 'LineWidth', line_width);

boxchart(ones(1, length(s1)), s1, ...

'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 1), ...

'BoxFaceColor', ColorOrder(:, 1));

boxchart(2 * ones(1, length(s2)), s2, ...

'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 2), ...

'BoxFaceColor', ColorOrder(:, 2));

boxchart(3 * ones(1, length(s3)), s3, ...

'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 3), ...

'BoxFaceColor', ColorOrder(:, 3));

%'MarkerEdgeColor', green.dark);

set(findobj(gcf,'-regexp','Tag','\w*Whisker'),'LineStyle','-')

median = findobj(gcf, 'type', 'line', 'Tag', 'Median');

set(median, 'Color', color_grey, 'LineWidth', line_width);

%% Final axes labels and options

title('Warmth');

xticks(1:3)

xticklabels({'Adaptive', 'Hardcoded', 'No Tag'})

xtickangle(45)

ylim([0 9])

yticks(1:9)

yticklabels({'1', '2', '3', '4', '5', '6', '7','8','9'})

ylabel('Rating')

% yline(1,'color',color_grey,'LineWidth',1);

hold on

scatter(1,mean(Warmth{2:19,2}),"+")

scatter(2,mean(Warmth{2:16,2}),"+")

scatter(3,mean(Warmth{2:15,2}),"+")

% plot([s5 s6 s7 ], 'db');

hold on

%% Prep axes

subplot(2,2,3)

hold on; grid on;

set(gca, 'YGrid', 'on', 'XGrid', 'off')

s1=Discomfort{1:15, 2};

s2=Discomfort{1:15, 3};

s3=Discomfort{1:15, 4};

%s5=mean(s1);

%s6=mean(s2);

%s7=mean(s3);

ColorOrder=[red.dark;blue.light;green.dark;purple.dark];

line_width=1.0;

b = boxchart(ones(1, length(s1)), s1);

set(b, 'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 1), ...

'BoxFaceColor', ColorOrder(:, 1))%,...

%'MarkerEdgeColor', green.dark);

set(findobj(gcf,'-regexp','Tag','\w*Whisker'),'LineStyle','-')

median = findobj(gcf, 'type', 'line', 'Tag', 'Median');

set(median, 'Color', color_grey, 'LineWidth', line_width);

boxchart(ones(1, length(s1)), s1, ...

'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 1), ...

'BoxFaceColor', ColorOrder(:, 1));

boxchart(2 * ones(1, length(s2)), s2, ...

'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 2), ...

'BoxFaceColor', ColorOrder(:, 2));

boxchart(3 * ones(1, length(s3)), s3, ...

'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 3), ...

'BoxFaceColor', ColorOrder(:, 3));

%'MarkerEdgeColor', green.dark);

set(findobj(gcf,'-regexp','Tag','\w*Whisker'),'LineStyle','-')

median = findobj(gcf, 'type', 'line', 'Tag', 'Median');

set(median, 'Color', color_grey, 'LineWidth', line_width);

hold on

%% Final axes labels and options

title('Discomfort');

xticks(1:3)

xticklabels({'Adaptive', 'Hardcoded', 'No Tag'})

xtickangle(45)

ylim([0 9])

yticks(1:9)

yticklabels({'1', '2', '3', '4', '5', '6', '7','8','9'})

ylabel('Rating')

% yline(1,'color',color_grey,'LineWidth',1);

hold on

scatter(1,mean(Discomfort{2:19,2}),"+")

scatter(2,mean(Discomfort{2:16,2}),"+")

scatter(3,mean(Discomfort{2:15,2}),"+")

% plot([s5 s6 s7 ], 'db');

hold off

hold on

print('-dpng', '-r300', 'plotting_example');

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

Answers (1)

Voss on 2 Jul 2023

  • Link

    Direct link to this answer

    https://matlabcentral.mathworks.com/matlabcentral/answers/1988233-how-to-switch-order-of-boc-plots#answer_1266063

  • Link

    Direct link to this answer

    https://matlabcentral.mathworks.com/matlabcentral/answers/1988233-how-to-switch-order-of-boc-plots#answer_1266063

Open in MATLAB Online

In order to swap the first boxchart ("Adaptive") with the third boxchart ("No Tag"), swap their xgroupdata (which is the first argument to boxchart); that is, give "Adaptive" xgroupdata = 3 and give "No Tag" xgroupdata = 1. Also do the same for the scatter plots of the means. And of course change the order of xticklabels.

I'll illustrate the old and new order - just for the "Competence" boxchart - below; you can apply the same changes to the "Warmth" and "Discomfort" boxcharts.

% a Competence variable that seems like what you're using:

Competence = array2table(9*rand(16,3));

This stuff doesn't change:

% Color Set

color_grey = [0.55,0.55,0.55];

green.fill = 1.08*[195,214,155]/255;

green.light = 0.9*[195,214,155]/255;

green.dark = 0.7*[195,214,155]/255;

purple.fill = 1.08*[179,162,199]/255;

purple.light = 0.9*[179,162,199]/255;

purple.dark = 0.7*[179,162,199]/255;

orange.fill = 1.06*[239,111,68]/255;

orange.light = 0.9*[239,111,68]/255;

orange.dark = 0.7*[239,111,68]/255;

blue.fill = 1.12*[142,180,227]/255;

blue.light = 0.9*[142,180,227]/255;

blue.med = 0.7*[142,180,227]/255;

blue.dark = 0.5*[142,180,227]/255;

red.dark = [153,0,0]/255;

red.fill = [255,102,102]/255;

%% Prep axes

figure

subplot(1,2,1)

hold on; grid on;

set(gca, 'YGrid', 'on', 'XGrid', 'off')

s1=Competence{1:15, 1};

s2=Competence{1:15, 2};

s3=Competence{1:15, 3};

ColorOrder=[red.dark;blue.light;green.dark;purple.dark];

line_width=1.0;

The old order:

boxchart(ones(1, length(s1)), s1, ...

'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 1), ...

'BoxFaceColor', ColorOrder(:, 1));

boxchart(2 * ones(1, length(s2)), s2, ...

'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 2), ...

'BoxFaceColor', ColorOrder(:, 2));

boxchart(3 * ones(1, length(s3)), s3, ...

'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 3), ...

'BoxFaceColor', ColorOrder(:, 3));

hold on

scatter(1,mean(Competence{2:15,2}),"+")

scatter(2,mean(Competence{2:16,2}),"+")

scatter(3,mean(Competence{2:15,2}),"+")

xticklabels({'Adaptive', 'Hardcoded', 'No Tag'})

This stuff doesn't change:

%% Final axes labels and options

title('Competence - Old Order');

xticks(1:3)

xtickangle(45)

ylim([0 9])

yticks(1:9)

yticklabels({'1', '2', '3', '4', '5', '6', '7','8','9'})

ylabel('Rating')

subplot(1,2,2)

hold on; grid on;

set(gca, 'YGrid', 'on', 'XGrid', 'off')

The new order:

boxchart(3 * ones(1, length(s1)), s1, ...

'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 1), ...

'BoxFaceColor', ColorOrder(:, 1));

boxchart(2 * ones(1, length(s2)), s2, ...

'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 2), ...

'BoxFaceColor', ColorOrder(:, 2));

boxchart(ones(1, length(s3)), s3, ...

'LineWidth', 1.0, ...

'BoxEdgeColor', ColorOrder(:, 3), ...

'BoxFaceColor', ColorOrder(:, 3));

scatter(3,mean(Competence{2:15,2}),"+")

scatter(2,mean(Competence{2:16,2}),"+")

scatter(1,mean(Competence{2:15,2}),"+")

xticklabels({'No Tag', 'Hardcoded', 'Adaptive'})

This stuff doesn't change:

%% Final axes labels and options

title('Competence - New Order');

xticks(1:3)

xtickangle(45)

ylim([0 9])

yticks(1:9)

yticklabels({'1', '2', '3', '4', '5', '6', '7','8','9'})

ylabel('Rating')

How to Switch order of Boc plots (3)

1 Comment

Show -1 older commentsHide -1 older comments

Voss on 15 Aug 2023

Direct link to this comment

https://matlabcentral.mathworks.com/matlabcentral/answers/1988233-how-to-switch-order-of-boc-plots#comment_2850667

  • Link

    Direct link to this comment

    https://matlabcentral.mathworks.com/matlabcentral/answers/1988233-how-to-switch-order-of-boc-plots#comment_2850667

@Ayan: Did this answer work for you?

Sign in to comment.

Sign in to answer this question.

See Also

Categories

MATLABGraphics2-D and 3-D PlotsData Distribution Plots

Find more on Data Distribution Plots in Help Center and File Exchange

Tags

  • boxchart
  • matlab
  • graph
  • boxplot
  • code

Community Treasure Hunt

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

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


How to Switch order of Boc plots (5)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

How to Switch order of Boc plots (2024)
Top Articles
Breaking News Futon Critic
charlotte cars & trucks "2500 4x4" - craigslist
Watch After Ever Happy 123Movies
Craigslist Free En Dallas Tx
Al Horford House Brookline
Academic Calendar Biola
Tear Of The Kingdom Nsp
Best Taq 56 Loadout Mw2 Ranked
Drift Boss 911
Q-global Web-based Administration, Scoring, and Reporting
Elgin Il Building Department
Brazos County Jail Times Newspaper
M&T Bank Atm Locations Near Me
Precision Garage Door Long Island
Sonic Fan Games Hq
Tacos Diego Hugoton Ks
Einfaches Spiel programmieren: Schritt-für-Schritt Anleitung für Scratch
Smart fan mode msi, what's it for and does it need to be activated?
Kinoprogramm für Berlin und Umland
The Nun 2 Showtimes Tinseltown
Splunk Append Search
Car Complaints Toyota
2887 Royce Road Varysburg Ny 14167
Yellow Kitchen Curtains Walmart
Craigslist Pets Baton Rouge La
Bannerlord How To Get Your Wife Pregnant
Irela Torres Only Fans
636-730-9503
Kyle Gibson Stats Vs Blue Jays 5 Games | StatMuse
Zen Leaf New Kensington Menu
Gulfport Senior Center Calendar
Advance Auto.parts Near Me
Noel Berry's Biography: Age, Height, Boyfriend, Family, Net Worth
Leccion 4 Lesson Test
Honeywell V8043E1012 Wiring Diagram
9 best hotels in Atlanta to check out in 2023 - The Points Guy
Target Minute Clinic Hours
Bullmastiff vs English Mastiff: How Are They Different?
Malibu Horror Story Showtimes Near Regal Atlantic Station
Probation中文
The Grand Canyon main water line has broken dozens of times. Why is it getting a major fix only now?
101 Riddles for Adults That Will Test Your Smarts
Shs Games 1V1 Lol
Kpq News Wenatchee Washington
Broadcastify Thurston County
Tapana Movie Online Watch 2022
Left Periprosthetic Femur Fracture Icd 10
Indian River County FL.
Tia V15.1 Update
What Does Wmt Contactless Mean
German police arrest 25 suspects in plot to overthrow state – DW – 12/07/2022
Edible Arrangements Track
Latest Posts
Article information

Author: Catherine Tremblay

Last Updated:

Views: 6341

Rating: 4.7 / 5 (67 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Catherine Tremblay

Birthday: 1999-09-23

Address: Suite 461 73643 Sherril Loaf, Dickinsonland, AZ 47941-2379

Phone: +2678139151039

Job: International Administration Supervisor

Hobby: Dowsing, Snowboarding, Rowing, Beekeeping, Calligraphy, Shooting, Air sports

Introduction: My name is Catherine Tremblay, I am a precious, perfect, tasty, enthusiastic, inexpensive, vast, kind person who loves writing and wants to share my knowledge and understanding with you.