Tutorials › Regression Analysis (Undergraduate) › Mapping Predictor Density With Rugs

Visualizing Relationships · Tutorial 67 of 991

Mapping Predictor Density With Rugs

Learn to read, construct, and interpret a predictor-axis rug alongside a scatterplot, including its strengths and limits.

Beginner 8 min read

What You'll Learn

  • Define a rug display and explain what each tick represents.
  • Read predictor concentrations and gaps from a scatterplot rug.
  • Calculate the share of observations within a predictor interval.
  • Recognize how ties and overplotting affect visible rug marks.
  • Distinguish a rug’s observed-value display from a smoothed density summary.

Why Add a Rug to a Scatterplot?

A scatterplot shows paired values: each point locates an observation by its predictor value and response value. That view is useful for seeing the relationship between the variables, but it can be hard to tell how observations are distributed along the predictor axis. A trend may look smooth even when many observations lie in one part of the horizontal range and very few lie elsewhere.

A rug display makes the predictor values easier to inspect. It adds a small tick mark on the horizontal axis for each observed predictor value. The marks form a compact visual record of where the observations occur, without adding another response summary or changing the scatterplot points.

Definition: A rug display is a row of short tick marks placed along an axis, with one mark at the location of each observation’s value on that axis. In a scatterplot of response \(Y\) against predictor \(X\), a predictor-axis rug places a mark at each observed \(x_i\). Close groups of marks show predictor values that occur near one another; widely separated marks show gaps or sparse portions of the observed predictor range.

The horizontal position of a rug mark carries the information: it shows an observed predictor value. Its short vertical length is only a plotting convention. The mark does not indicate the response value, the size of the response, or a fitted trend. Those remain represented by the scatterplot points and any other plotted summaries.

Reading the Predictor Values Along the Axis

A rug is most helpful when read together with the scatterplot. First note where the ticks are concentrated, spread out, or absent. Then look at the points above those locations to see the response values paired with the observed predictors. The rug can reveal whether a visually prominent part of a pattern corresponds to many observations or only a few.

A simple way to make this idea precise is to count observations in an interval of predictor values. If \(a\) and \(b\) are endpoints, the number of observations in the interval from \(a\) to \(b\) can be written as

$$ N_{[a,b]} = \sum_{i=1}^{n} I(a \le x_i \le b), $$

where \(I(\text{condition})\) equals 1 when the condition is true and 0 otherwise. The fraction of all observations in that interval is \(N_{[a,b]}/n\). On a rug, this fraction corresponds to the share of marks whose horizontal positions fall between \(a\) and \(b\). The rug does not print the count or fraction for you, but it gives a direct visual guide to where they are larger or smaller.

This relationship follows directly from how the display is constructed. Each observed value \(x_i\) produces exactly one mark at horizontal coordinate \(x_i\). Counting marks in an interval therefore counts exactly the observations whose predictor values are in that interval. Nothing in this mapping uses the associated response values \(y_i\).

Worked Example: Finding Crowded and Sparse Predictor Intervals

Suppose a hypothetical scatterplot shows 12 patients’ recorded treatment durations \(x\), in days. The values are \(2, 2, 3, 4, 4, 4, 5, 6, 8, 9, 9, 12\). A rug is drawn beneath the horizontal axis. Describe where its marks are concentrated, and calculate the shares in three intervals.

Each of the 12 values contributes one tick. The interval from 2 through 5 days contains \(2, 2, 3, 4, 4, 4, 5\), or 7 observations. Its share is

$$ \frac{N_{[2,5]}}{n} = \frac{7}{12} \approx 0.583 = 58.3\%. $$

The interval from 6 through 9 days contains \(6, 8, 9, 9\), or 4 observations:

$$ \frac{N_{[6,9]}}{n} = \frac{4}{12} \approx 0.333 = 33.3\%. $$

The interval from 10 through 12 days contains only the value 12, so its share is \(1/12 \approx 8.33\%\). The rug should look most crowded from 2 to 5 days, less crowded from 6 to 9 days, and very sparse from 10 to 12 days. There are no observed values between 9 and 12 days except at 12; the long horizontal gap makes that feature visible. These percentages describe the 12 hypothetical observations, not a broader population unless a suitable sampling design supports that interpretation.

How to Construct and Inspect a Rug

A clear predictor rug is simple, but its placement and scale matter. The following steps keep the display aligned with the plotted observations.

1
Choose the predictor axis.
For a scatterplot of \(Y\) against \(X\), use the horizontal axis if the goal is to show where the observed predictor values occur.
2
Place one tick per observation.
Put each tick directly under the corresponding \(x_i\) location, using the same axis scale as the scatterplot. The ticks should not be shifted left or right from their data values.
3
Compare local concentrations.
Look for stretches with many nearby ticks, stretches with only a few, and intervals with no observed ticks. Keep the scatterplot visible so the predictor distribution can be considered alongside the response pattern.
4
Check ties and readability.
If several observations have exactly the same predictor value, their marks occupy the same horizontal location. Make sure this overlap is not mistaken for a single observation.

The same construction can be used for a vertical axis when the goal is to show where response values occur, but that is a different reading task. Here, the rug is specifically a display of predictor values. Keeping this purpose in mind prevents a common visual misreading: a tick’s position along the horizontal axis says where \(x_i\) lies, while the scatterplot point above it says which response \(y_i\) was paired with that predictor value.

Worked Example: Reading a Rug With Repeated Predictor Values

A hypothetical study records a predictor \(x\), the number of practice sessions completed, for 10 participants. The values are \(0, 0, 0, 1, 1, 2, 2, 2, 2, 4\). What would a basic rug show, and what should the reader be careful about?

There are 10 observations, so the rug represents 10 predictor values. Three ticks share the location \(x=0\), two share \(x=1\), four share \(x=2\), and one lies at \(x=4\). The greatest concentration is at 2 sessions. There are no observed values at 3 sessions, and the single value at 4 is separated from the group at 2 by a gap.

The basic ticks at \(x=0\), \(x=1\), and \(x=2\) coincide because the predictor values are tied. If identical ticks are drawn on top of one another, the display may make three, two, or four observations look like one dark or thick mark. Thus the marks do not always let a reader count ties reliably. A graphing program might show coincident marks with slight vertical stacking or another clear convention, but the horizontal position must remain faithful to the recorded value. The interpretation is about repeated predictor values, not about a response pattern.

What a Rug Shows—and What It Does Not

A rug is a direct display of observed values, rather than a smooth curve or a model of the predictor distribution. It is useful because it preserves the actual locations of the data: a tick corresponds to a recorded observation, and an empty stretch means no recorded predictor values fall there at the displayed resolution. It does not by itself estimate how common unobserved values might be in a wider population.

A rug also has limits. When the sample is large, a row of ticks can become too dense to distinguish individual marks. With repeated or rounded values, overlapping ticks can obscure the number of observations at a location. Conversely, a very small sample may produce a scattered row of marks that is easy to inspect but does not summarize a stable population pattern. The graphic should be read as a view of the data at hand.

A rug is not a histogram: a histogram groups observations into bins and represents the counts or frequencies in those bins with bars, while a rug places a mark at each observed value. Nor is it a smoothed density curve: the rug adds no smoothing rule and no estimated curve. These displays answer related but different visual questions, so the choice depends on whether exact observed locations or an aggregated summary is most useful.

Worked Example: Separating Predictor Concentration From Response Pattern

Consider a hypothetical scatterplot of daily outdoor temperature \(x\), in degrees Celsius, and electricity use \(y\), in kilowatt-hours, for 9 days. The recorded temperatures are \(10, 11, 11, 12, 13, 18, 20, 21, 22\). A rug is placed below the horizontal axis. Describe what the rug communicates and what it cannot establish about the plotted relationship.

The temperatures from 10 through 13 degrees account for five of the nine observations. The temperatures from 18 through 22 degrees account for four. There are no observed predictor values from 14 through 17 degrees. The rug therefore shows a cluster of observed temperatures at the lower end, another group at the higher end, and a gap between them.

That is information about the distribution of the predictor among these nine days. To describe how electricity use varies with temperature, one must inspect the scatterplot points: the rug contains no \(y\)-coordinates. For example, the ticks alone cannot tell whether the response increases or decreases as temperature changes, whether the relationship bends, or how much electricity use varies at a given temperature. Those features are in the paired points, not in the rug. A rug can make the predictor coverage easier to see, but it does not substitute for examining the relationship itself.

Common Mistakes

  • Counting a tie as one observation. Several ticks at the same horizontal location may overlap. A thick-looking mark need not be one observation; check how repeated values are displayed or consult the data.
  • Reading a tick as a response value. A predictor rug mark encodes only an \(x_i\) location. The response is shown by the scatterplot point paired with it.
  • Treating a gap as an unobserved trend. No tick in an interval means no recorded predictor value is displayed there. It does not reveal what the response would be at values not observed.
  • Calling the rug a density estimate. The ticks are the observed values themselves; no smoothing or density calculation has been applied.
  • Comparing tick counts without considering sample size. A larger data set can show more ticks overall. When comparing proportions, relate the count in a range to the total number of observations in that data set.
Key takeaway: A predictor rug adds one horizontal tick for each observed predictor value. Use its concentrations and gaps to see where the data lie along the predictor axis, while using the scatterplot points to study the paired response pattern.

Check Your Understanding

Try these questions using the definitions and examples above.

  1. In a scatterplot of response \(Y\) against predictor \(X\), what does the horizontal position of a rug tick represent?
  2. A predictor rug has 15 observations, and 6 ticks fall between 3 and 5 units, inclusive. What fraction of the observations is in that interval?
  3. Why might four observations with the same predictor value appear as only one visible location on a basic rug?
  4. What can an empty stretch of the rug tell you about the observed predictor values, and what can it not tell you about the response?
  5. How does a rug display differ from a histogram of the predictor values?