+static void
+show_spreadlevel (const struct examine *cmd, int iact_idx)
+{
+ const struct interaction *iact = cmd->iacts[iact_idx];
+ const size_t n_cats = categoricals_n_count (cmd->cats, iact_idx);
+
+ int v;
+
+ /* Spreadlevel when there are no levels is not useful */
+ if (iact->n_vars == 0)
+ return;
+
+ for (v = 0; v < cmd->n_dep_vars; ++v)
+ {
+ int grp;
+ struct chart_item *sl;
+
+ struct string label;
+ ds_init_cstr (&label,
+ var_to_string (cmd->dep_vars[v]));
+
+ if (iact->n_vars > 0)
+ {
+ ds_put_cstr (&label, " (");
+ interaction_to_string (iact, &label);
+ ds_put_cstr (&label, ")");
+ }
+
+ sl = spreadlevel_plot_create (ds_cstr (&label), cmd->sl_power);
+
+ for (grp = 0; grp < n_cats; ++grp)
+ {
+ const struct exploratory_stats *es =
+ categoricals_get_user_data_by_category_real (cmd->cats, iact_idx, grp);
+
+ double median = percentile_calculate (es[v].quartiles[1], cmd->pc_alg);
+
+ double iqr = percentile_calculate (es[v].quartiles[2], cmd->pc_alg) -
+ percentile_calculate (es[v].quartiles[0], cmd->pc_alg);
+
+ spreadlevel_plot_add (sl, iqr, median);
+ }
+
+ if (sl == NULL)
+ msg (MW, _("Not creating spreadlevel chart for %s"), ds_cstr (&label));
+ else
+ chart_item_submit (sl);
+
+ ds_destroy (&label);
+ }
+}
+