Comparing Assembled Graphs

It is good practice to set a common range for the assembled graphs axes enabling a more natural comparison as everything is on the same scale.

Using default range

Values of second graph are much bigger than those of the first one, but this is not well appreciated at first sight.

y1 = rand(1,30)		

% defining Y values for first graph

y2 = rand(1,30)*10

% defining Y values for second graph

o1 = struct

% initializing options struct, first graph options

o1.show = false b1 = bar(y1,o1) o2 = o1

% initializing options struct, second graph options

b2 = bar(y2,o2) o = struct

% initializing options struct, options for assemble

o.width = 1200 assemble({b1,b2},o)

Specifying a common range

Calculating the maximum value of the graphs to compare, and setting it as the value for the 'yAxisMax' option for both graphs, we will have a better visualization.

y1 = rand(1,30)		

% defining Y values for first graph

y2 = rand(1,30)*10

% defining Y values for second graph

ymax = max([y1 y2])

% finding maximum value of both graphs

o1 = struct

% initializing options struct, first graph options

o1.show = false o1.yAxisMax = ymax

% setting ymax as maximum value of Y-axis

b1 = bar(y1,o1) o2 = o1

% initializing options struct, second graph options

o2.yAxisMax = ymax

% setting ymax as maximum value of Y-axis

b2 = bar(y2,o2) o = struct

% initializing options struct, options for assemble

o.width = 1200 assemble({b1,b2},o)

Related functions

assemble