Search code examples
matlabplotbar-chartmatlab-figure

How to plot the following figure via matlab hist function?


How to plot the following figure via matlab hist function?

Group 1: [10, 10, 20]; and Group 2: [15, 10, 8]. Each group consists of three algorithms' running times.

enter image description here


Solution

  • HIST is not a solution to your problem. Please try to look for the bar function

    A sample snippet may look like

    g1 = [10,10,20];
    g2 = [15,10,8];
    algStr = sprintfc('Algorithm %d',1:3);
    bar(categorical({'Group1','Group2'}),[g1;g2])
    legend(algStr)
    

    You will also need to learn how to tweak the axes of the figure to match exactly to your sample graph. But I think I will leave it for you to find out.