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

RIDGELINE PLOT

Name:
    RIDGELINE PLOT
Type:
    Graphics Command
Purpose:
    Generates a ridgeline plot.
Description:
    A ridgeline plot displays kernel density plot (or alternatively histograms) for multiple data sets on a single plot. A common scale is used for the horizontal axis and the plots may overlap on the vertical axis.

    The degree of overlap can be controlled with the command

      SET RIDGELINE PLOT HEIGHT <inc>

    where <inc> is a positive value. The default value is 1. You may need to generate several iterations of the plot to find a value that works best. The desired degree of overlap is a matter of personal preference, so Dataplot does not try to automatically determine an optimal value.

    To specify the desired type of plot, enter the command

      SET RIDGELINE PLOT TYPE <DENSITY/CUMULATIVE DENSITY/
                                          HISTOGRAM/CUMULATIVE HISTOGRAM>

    The default, DENSITY, generates a kernel density plot. The HISTOGRAM option generates a relative histogram. The DENSITY and HISTOGRAM options are estimating the probability densities of the data sets. Selecting the CUMULATIVE DENSITY and CUMULATIVE HISTOGRAM will plot estimates of the cumulative distribution functions.

    This plot works best when there is a clear pattern in the density estimates.

Syntax 1:
    RIDGELINE PLOT <y> <x>             <SUBSET/EXCEPT/FOR qualification>
    where <y> is a response variable;
                <x> is a group-id variable;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.
Syntax 2:
    MULTIPLE RIDGELINE PLOT <y1> ... <yk>
                            <SUBSET/EXCEPT/FOR qualification>
    where <y1> ... <yk> is a list of one or more response variables;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.
Examples:
    RIDGELINE PLOT Y X
    RIDGELINE PLOT Y X SUBSET X > 2
    MULTIPLE RIDGELINE PLOT Y1 Y2 Y3 Y4 Y5
Note: Note:
    The Program examples below show how to control the appearance of the plot.
Note:
    The HORIZONTAL SWITCH command can be used to draw these graphs vertically rather than horizontally. This is demonstrated in the program example below.
Default:
    None
Synonyms:
    None
Related Commands: Reference:
    Wilke, C. O.(2019), "Fundamentals of data visualization: a primer on making informative and compelling figures," O'Reilly Media (see pages 39, 43 88-91, 196).
Applications:
    Distributional Analysis
Implementation Date:
    2025/06
Program 1:
     
    . Step 1:   Read yearly Freon and CO-2 data
    .
    SET READ FORMAT 3F4.0,F5.0,F6.0,F3.0,2F9.0
    SKIP 50
    READ PBF11.DAT YEAR DAY J1 J2 FREON FLAG WV CO2
    retain year co2 subset co2 > 0
    let y = co2
    let yeardist = distinct year
    let nyears = size yeardist
    loop for k = 1 1 nyears
        let aval = yeardist(k)
        let string s^k = ^aval
    end of loop
    let ig = group label s1 to s^nyears
    .
    . Step 2:   Set basic plot control features
    .
    case asis
    title case asis
    label case asis
    tic mark label case asis
    title offset 1
    title size 1.8
    .
    let inc = 0.1
    let xmax = (nyears-1)*inc
    xlimits 0 xmax
    major xtic mark number nyears
    minor xtic mark number 0
    tic mark offset units data
    x1tic mark offset 0.05  0.2
    x1tic mark label format group label
    x1tic mark label content ig
    ylimits 320 360
    horizontal switch on
    .
    . Step 3:   Generate the plot for kernel density
    .
    y1label CO2 Level
    x1label Year
    title Kernel Density Traces for CO2 (Point Barrow)
    set ridgeline plot height inc
    ridgeline plot y year
        
    .
    . Step 4:   Now generate using histograms rather than density traces
    .
    class lower 320
    class upper 360
    class width 2
    bar fill on all
    bar fill color cyan red cyan red cyan red cyan red cyan red
    .
    let inc = 0.15
    let xmax = (nyears-1)*inc
    xlimits 0 xmax
    major xtic mark number nyears
    minor xtic mark number 0
    tic mark offset units data
    x1tic mark offset 0.05  0.2
    .
    title Histograms for CO2 (Point Barrow)
    set ridgeline plot height inc
    set ridgeline plot type histogram
    ridgeline plot y year
        
        
Program 2:
     
    . Step 1:   Read yearly Freon and CO-2 data
    .
    SET READ FORMAT 3F4.0,F5.0,F6.0,F3.0,2F9.0
    SKIP 50
    READ PBF11.DAT YEAR DAY J1 J2 FREON FLAG WV CO2
    retain year co2 subset co2 > 0
    let y = co2
    let yeardist = distinct year
    let nyears = size yeardist
    loop for k = 1 1 nyears
        let aval = yeardist(k)
        let string s^k = ^aval
    end of loop
    let ig = group label s1 to s^nyears
    .
    . Step 2:   Set basic plot control features
    .
    case asis
    title case asis
    label case asis
    tic mark label case asis
    title offset 1
    title size 1.8
    .
    let inc = 1
    let xmax = (nyears-1)*inc
    xlimits 0 xmax
    major xtic mark number nyears
    minor xtic mark number 0
    tic mark offset units data
    x1tic mark offset 0.1  1.1
    x1tic mark label format group label
    x1tic mark label content ig
    ylimits 320 360
    horizontal switch on
    .
    . Step 3:   Generate the plot for cumulative kernel density
    .
    y1label CO2 Level
    x1label Year
    title Cumulative Kernel Density Traces for CO2 (Point Barrow)
    set ridgeline plot type cumulative density
    set ridgeline plot height inc
    ridgeline plot y year
        
    .
    . Step 4:   Generate the plot for cumulative histogram
    .
    class lower 320
    class upper 360
    class width 2
    bar fill on all
    bar fill color cyan red cyan red cyan red cyan red cyan red
    .
    title Cumulative Histograms for CO2 (Point Barrow)
    set ridgeline plot type cumulative histogram
    ridgeline plot y year
        
Date created: 07/15/2025
Last updated: 07/15/2025

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