Search Locate Previous Next Contents

CategoriseBy – category variable

Scatter plots can take a matrix of values, with the X-variable in column-1 and as many Y-variables as required in columns 2-n. It may be more convenient to specify the y-data as a simple vector and split it automatically with a category variable:

ch.Set 'xvar' farm
ch.Set 'cvar' year
ch.Scatter yield

This style is likely to be particularly useful if the data has come from a database table, where it can be quite tedious to separate the values on the basis of one or more category columns (say Sales in tonnes by region). If the category variable is text, it is sorted alphabetically and the unique values are used as the keys. This is also a convenient way to generate a grouped barchart or multiple piechart.

There are two simple cover functions vs and by in the RainPro workspace to allow expressions like:

ch.Scatter yield vs variety by year

You can experiment with the infamous barley data here!

See also ...
ch.Boxplot – box and whisker charts
CategoriseInto – categorisation buckets
Tease – separation of scatter plots
Versus – scatter versus this


Continue to: CategoriseInto – categorisation buckets
© Copyright Causeway Graphical Systems Ltd 2003