barVariableWidth produces a bar plot with different widths and colors for each bar
close all
% The following table shows the frequency distribution of the firms in
% correspondence of the different classes of number of employees
labels={'10-20' '20-30' '30-50' '50-100' '100-170'};
freqs=[132; 180; 60; 48; 20];
T=array2table(freqs,'RowNames',labels,'VariableNames',{'Frequency distribution'});
disp(T);
% Show the plot of the frequency densities (frequency/class width)
% widths= vector which contains the width of the classes
widths=[10; 10; 20; 50; 70];
classes=[10; 20; 30; 50; 100; 170];
dens=freqs./widths;
% Show the plot
barVariableWidth(dens,classes)
xlabel('Employees')
ylabel('Frequency density')
heights — y-coordinates.
Vector.Vector Vector of length k containing numeric values describing the bars which make up the plot.
Data Types: single| double
classes — classes of the frequency distribution.
Vector.Vector of length k+1 containing numeric values describing the widths of the bars which make up the plot. classes(1) contains the starting point of the first bar on the x axis, and classes(end) contains the end point of the last bar on the x axis.
For example if classes=[0.5 0.6 0.9 1 1.2]; the first baar has x coordinates [0.5 0.6], the second bar has x coordinates [0.6 0.9], the third has x coordinates [0.9 1] and the fourth has x coordinates [1 1.2]
Data Types: single| double
Specify optional comma-separated pairs of Name,Value arguments.
Name is the argument name and Value
is the corresponding value. Name must appear
inside single quotes (' ').
You can specify several name and value pair arguments in any order as
Name1,Value1,...,NameN,ValueN.
'color',1:5
, 'LineWidth',2
, 'FaceAlpha',0.8
, 'EdgeColor',[0 0.5 1]
, 'LineStyle','--']
Color
—Rectangle colors.scalar | vector | matrix | RGB triplet | 'r' | 'g' | 'b' | .Rectangle colors, specified as a scalar, vector, matrix, or a color name.
Example: 'color',1:5
Data Types: scalar | vector | matrix | RGB triplet | 'r' | 'g' | 'b' | .
LineWidth
—Line Width of the vertices.scalar.Scalar containing the width of the lines of the rectangles.
Example: 'LineWidth',2
Data Types: double
FaceAlpha
—Face transparency.1 (default) | scalar in range [0,1] | 'flat' | 'interp'.A value of 1 is fully opaque and 0 is completely transparent.
For additional details about this option see option FaceAlpha inside patch.
Example: 'FaceAlpha',0.8
Data Types: double
EdgeColor
—Edge colors.[0 0 0] (default) | 'none' | 'flat' | 'interp' | RGB triplet | hexadecimal color code | 'r' | 'g' | 'b' | .Colors of the edges of the rectangles.
For additional details about this option see option FaceAlpha inside patch.
Example: 'EdgeColor',[0 0.5 1]
Data Types: | 'none' | 'flat' | 'interp' | RGB triplet | hexadecimal color code | 'r' | 'g' | 'b' |
LineStyle
—Line style.'-' (default) | '--' | ':' | '-.' | 'none'' Line Style of the edges of the rectangles.
Example: 'LineStyle','--']
Data Types: '-' (default) | '--' | ':' | '-.' | 'none''