barVariableWidth

barVariableWidth produces a bar plot with different widths and colors for each bar

Syntax

  • barVariableWidth(heights, classes)example
  • barVariableWidth(heights, classes,Name,Value)example

Description

example

barVariableWidth(heights, classes) barVariableWidth with all default options.

example

barVariableWidth(heights, classes, Name, Value) Example in stackoverflow.

Examples

expand all

  • barVariableWidth with all default options.
  • 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')

  • Example in stackoverflow.
  • https://stackoverflow.com/questions/18419339/how-to-plot-bar-with-different-height-and-differenth-width-in-matlab

    close all
    x = [0.5 0.6 0.9 1 1.2 1.8];
    dy = [1 3 2 .5 .1];
    barVariableWidth(dy,x)
    xlabel('Time')
    ylabel('Prob density')
    Click here for the graphical output of this example (link to Ro.S.A. website). Graphical output could not be included in the installation file because toolboxes cannot be greater than 20MB. To load locally the image files, download zip file http://rosa.unipr.it/fsda/images.zip and unzip it to <tt>(docroot)/FSDA/images</tt> or simply run routine <tt>downloadGraphicalOutput.m</tt>

    Related Examples

    expand all

  • Example in stackoverflow (different colors).
  • https://stackoverflow.com/questions/18419339/how-to-plot-bar-with-different-height-and-differenth-width-in-matlab

    close all
    x = [0.5 0.6 0.9 1 1.2 1.8];
    dy = [1 3 2 .5 .1];
    barVariableWidth(dy,x,'Color',1:5)
    xlabel('Time')
    ylabel('Prob density')
    Click here for the graphical output of this example (link to Ro.S.A. website)

  • Example in stackoverflow (option FaceAlpha).
  • https://stackoverflow.com/questions/18419339/how-to-plot-bar-with-different-height-and-differenth-width-in-matlab

    close all
    x = [0.5 0.6 0.9 1 1.2 1.8];
    dy = [1 3 2 .5 .1];
    barVariableWidth(dy,x,'FaceAlpha',0.1)
    xlabel('Time')
    ylabel('Prob density')
    title('Option ''FaceAlpha''')
    Click here for the graphical output of this example (link to Ro.S.A. website)

  • Example in stackoverflow (option LineWidth).
  • https://stackoverflow.com/questions/18419339/how-to-plot-bar-with-different-height-and-differenth-width-in-matlab

    close all
    x = [0.5 0.6 0.9 1 1.2 1.8];
    dy = [1 3 2 .5 .1];
    barVariableWidth(dy,x,'LineWidth',3)
    xlabel('Time')
    ylabel('Prob density')
    title('Option ''LineWidth''')
    Click here for the graphical output of this example (link to Ro.S.A. website)

  • Example in stackoverflow (option EdgeColor).
  • https://stackoverflow.com/questions/18419339/how-to-plot-bar-with-different-height-and-differenth-width-in-matlab

    close all
    x = [0.5 0.6 0.9 1 1.2 1.8];
    dy = [1 3 2 .5 .1];
    barVariableWidth(dy,x,'EdgeColor','r')
    xlabel('Time')
    ylabel('Prob density')
    title('Option ''EdgeColor''')
    Click here for the graphical output of this example (link to Ro.S.A. website)

  • Example in stackoverflow (option LineStyle).
  • https://stackoverflow.com/questions/18419339/how-to-plot-bar-with-different-height-and-differenth-width-in-matlab

    close all
    x = [0.5 0.6 0.9 1 1.2 1.8];
    dy = [1 3 2 .5 .1];
    barVariableWidth(dy,x,'LineStyle','--')
    xlabel('Time')
    ylabel('Prob density')
    title('Option ''LineStyle''')
    Click here for the graphical output of this example (link to Ro.S.A. website)

    Input Arguments

    expand all

    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

    Name-Value Pair Arguments

    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.

    Example: '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''

    Output Arguments

    References

    See Also

    This page has been automatically generated by our routine publishFS