File Exchange

image thumbnail

rug plots

version (2.61 KB) by Rob Campbell
Creates a so-called "rug" plot similar to those produced by the free stats package, R.


Updated 18 Jun 2010

View License

A rug plot is a compact way of illustrating the marginal distributions of a variable along x and y. Positions of the data points along x and y are denoted by tick marks, reminiscent of the tassels on a rug.

Known Issues:
Rug marks are overlaid onto the same axis as the original data. Changing the axis dimensions after calling rug will therefore cause the tick marks to become disassociated from the axes.

I haven't tested this function extensively so let me know if you find any problems.

Comments and Ratings (3)

Rob Campbell

Captain, what you want to do is make your plot then do:
>> R=rug;
>> delete(R.yRug)

See the function help. Your usage "rug(x)" is not a valid way of calling the function.


% I want to show "rug" on X-axis only, how? it seems wrong, thanks for reply.

Nice -- did what I expected for a few quick tests.
Feature request: allow addition of 'jitter' to data so that repeated values are drawn with slight offsets so as to provide better qualitative view of the density. (I believe the R function has this option).


minor updates to summary

Tidy and correct comments. Check that tickScaleFactor is between 0 and 1.

Allow tick mark length to be defined at the command line.

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: marginalscatter