SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 2 Vol 1

VARIABLE WIDTH BAR PLOT

Name:
    VARIABLE WIDTH BAR PLOT
Type:
    Graphics Command
Purpose:
    Generates a variable width bar plot.
Description:
    The basic bar plot is based on a single response variable that controls the height of the bar (basic bar plots are generated with Dataplot by using the PLOT command with appropriate settings for the BAR and related attribute setting commands for the bars). The variable width bar plot adds a second response variable that controls the width of the bars.

    Optionally, an additional tag variable can be specified. Rows that have the same value for the tag variable will use the same attributes for the bars. The lowest value of the tag variable will use the first setting of the BAR attribute commands, the second lowest value will use the second setting of the BAR attribute commands and so on. This is most typically used to control the color of the bars. If no tag variable is specified, then all bars will be drawn with the same attributes.

Syntax 1:
    VARIABLE WIDTH BAR PLOT <y1> <y2>
                            <SUBSET/EXCEPT/FOR qualification>
    where <y1> is the variable that controls the height of the bar;
                <y2> is the variable that controls the width of the bar;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    With this syntax, all bars will be drawn with the same attributes. The <y1> and <y2> variables must have the same number of observations.

Syntax 2:
    VARIABLE WIDTH BAR PLOT <y1> <y2> <tag>
                            <SUBSET/EXCEPT/FOR qualification>
    where <y1> is the variable that controls the height of the bar;
                <y2> is the variable that controls the width of the bar;
                <tag> is a variable that specifies which bars are drawn with the same attributes; and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    With this syntax, bars that have the same value for the <tag> variable will be drawn with the same attributes. Most typically, this is used to specify the fill color for the bars. The <y1>, <y2> and <tag> variables must have the same number of observations.

    The use of the <tag> variable is demonstrated in the Program example below.

Examples:
    VARIABLE WIDTH BAR PLOT Y1 Y2
    VARIABLE WIDTH BAR PLOT Y1 Y2 TAG
    VARIABLE WIDTH BAR PLOT Y1 Y2 SUBSET Y2 > 0
Note:
    Dataplot provides two options for the bar widths.

    1. In the first option, the bar width is set to 1 for the maximum value of the second response variable. The remaining bar widths are set proportional to this maximum width. For example, if the maximum value for the second response variable is 20, a value of 5 for the second response variable would result in a bar width of 5/20 (= 0.25). With this option the bars are not connected. The advantage of this method is that it is easier to make the axis labels legible.

    2. In the second option, the total width is calculated as the sum of the values in the second response variable plus one. Then the individual bar widths are set to proportional to the total width. So if the total width is 100 and a given value of the second response variable is 30, the bar width for that observation will be 30/100 (= 0.3). With this option, the bars are connected. This option may be preferred when there are a large number of response values.

    To set this option, enter the command

      SET VARIABLE WIDTH BAR PLOT CONNECTED <ON/OFF>

    The default is OFF (i.e., option 1).

Default:
    SET VARIABLE WIDTH BAR PLOT CONNECTED OFF
Synonyms:
    VARIABLE WIDTH BAR CHART
Related Commands: Applications:
    Presentation Graphics
Implementation Date:
    2025/06
Program:
     
    skip 25
    column limits 1 29
    read subject.dat number perwomen type
    skip 0
    let n = size number
    column limits 30 80
    loop for k = 1 1 n
        let irow = 25 + k
        row limits irow irow
        read string subject.dat  subj^k
    end of loop
    column limits
    row limits
    let ig = group label subj1 to subj^n
    .
    . Step 2:   Set some plot control
    .
    case asis
    title case asis
    label case asis
    tic mark label case asis
    .
    horizontal switch on
    ylimits 1 n
    major y1tic mark number n
    minor y1tic mark number 0
    tic mark offset units data
    y1tic mark offset 0.8 0.8
    y1tic mark label format group label
    y1tic mark label content ig
    y1label Subject
    y1label displacement 21
    .
    x1limits 0  15000
    x1label Number of Entrants
    x2label Width of Bar: Percentage of Women
    x3label Blue: Theoretical Subject, Red: Vocational Subject
    .
    frame corner coordinate 25 20 95 90
    title Variable Width Bar Chart
    bar fill color blue red
    .
    . Step 3:   Generate the plot
    .
    set variable width bar plot connected off
    variable width bar plot number perwomen type
    .
    . Step 4:   Now generate with "connected" option ON
    .
    ylimits 1 n
    major y1tic mark number n
    minor y1tic mark number 0
    tic mark offset units data
    y1tic mark offset 1.0 2.2
    y1tic marks off
    y1tic mark labels off
    .
    set variable width bar plot connected on
    variable width bar plot number perwomen type
        
    .
    .           Now generate the y-axis tic mark labels
    .
    justification rice
    let xcoor = 23
    .
    loop for k = 1 1 n
        let ycoor = xplot(k)
        movesd xcoor ycoor
        text ^subj^k
    end of loop
        
Date created: 06/30/2025
Last updated: 06/30/2025

Please email comments on this WWW page to [email protected].