plot_rating_grid
plot_rating_grid(data=None, prefix=None, levels=None, digits=2, **kwargs)A stacked rating chart for a whole block of questions.
The one-line form of plot_stacked_rating() for the common case: a block of columns sharing a prefix, each asking the same rating question about a different feature or brand. Tabulates the block, tidies the question names, numbers the answers by their position on the scale and stacks the result.
A wording that is not on the scale cannot be numbered, so it is reported rather than silently dropped into an unlabelled segment, and two different answers landing on one rank (which means levels is short of a level) are reported too. Registering the block once with register_order() removes the levels argument from every later call.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| data | pandas.DataFrame | A data frame. If omitted, the session default is used. | None |
| prefix | str | The block’s shared column prefix, e.g. “ratings_”. It is stripped from the feature labels. | None |
| levels | list of str | The scale’s answer wordings, worst first. None (default) looks the block up in the order registry, falling back to the five-point default of recode_likert(). |
None |
| digits | int | Decimal places kept in the underlying percentages. Default 2. | 2 |
| **kwargs | Passed to plot_stacked_rating() (palette, label_min, show_average). |
{} |
Returns
| Name | Type | Description |
|---|---|---|
| plotnine.ggplot | The chart. |
See Also
plot_stacked_rating, calc_percentage_batch, register_order
Examples
>>> plot_rating_grid(podracing_survey, "ratings_")
>>> plot_rating_grid(podracing_survey, "partner_likeability_",
... levels=["Very unlikeable", "Unlikeable", "Likeable", "Very likeable"])