Plot ranking
- plot_utils.plot_ranking(ranking, fig=None, ax=None, figsize='auto', dpi=100, barh=True, top_n=None, score_ax_label=None, name_ax_label=None, invert_name_ax=False, grid_on=True)[source]
Plot rankings as a bar plot (in descending order), such as:
^ | dolphin ||||||||||||||||||||||||||||||| | cat ||||||||||||||||||||||||| | rabbit |||||||||||||||| | dog ||||||||||||| | -|------------------------------------> Age of pet 0 1 2 3 4 5 6 7 8 9 10 11
- Parameters:
ranking (dict or pandas.Series) –
- The ranking information, for example:
{‘rabbit’: 5, ‘cat’: 8, ‘dog’: 4, ‘dolphin’: 10}
It does not need to be sorted externally.
fig (matplotlib.figure.Figure or
None
) – Figure object. If None, a new figure will be created.ax (matplotlib.axes._subplots.AxesSubplot or
None
) – Axes object. If None, a new axes will be created.figsize ((float, float)) – Figure size in inches, as a tuple of two numbers. The figure size of
fig
(if notNone
) will override this parameter.dpi (float) – Figure resolution. The dpi of
fig
(if notNone
) will override this parameter.barh (bool) – Whether or not to show the bars as horizontal (otherwise, vertical)
top_n (int) – If
None
, show all categories.top_n
> 0 means showing the highesttop_n
categories.top_n
< 0 means showing the lowest |``top_n``| categories.score_ax_label (str) – Label of the score axis (e.g., “Age of pet”).
name_ax_label (str) – Label of the “category name” axis (e.g., “Pet name”).
invert_name_ax (bool) – Whether to invert the “category name” axis. For example, if
invert_name_ax
isFalse
, then higher values are shown on the top ifbarh
isTrue
.grid_on (bool) – Whether or not to show grids on the plot.
- Returns:
fig (matplotlib.figure.Figure) – The figure object being created or being passed into this function.
ax (matplotlib.axes._subplots.AxesSubplot) – The axes object being created or being passed into this function.