inequality.pen.pen#
- inequality.pen.pen(df, col, x, weight=None, ascending=True, xticks=True, total_bars=100, figsize=(8, 6), ax=None)[source]#
Creates the Pen’s Parade visualization.
This function generates a bar plot sorted by a specified column, with options to customize the x-axis ticks and figure size. The Pen’s Parade is a visual representation of income distribution (or similar data), typically used to show inequality.
- Parameters:
- df
pd.DataFrame
DataFrame containing the data to plot.
- col
str
The column to plot on the y-axis.
- x
str
The column to plot on the x-axis.
- weight
str
,optional
A column used to weight the bars in the Pen’s Parade. Default is None.
- ascendingbool,
optional
Whether to sort the DataFrame in ascending order by the col. Default is True.
- xticksbool,
optional
Whether to show x-axis ticks. Default is True.
- total_bars
int
,optional
Total number of bars to create for the weighted Pen’s Parade. Default is 100.
- figsize
list
,optional
The size of the figure as a list [width, height]. Default is [8, 6].
- ax
matplotlib.axes.Axes
,optional
Matplotlib Axes instance to plot on. If None, a new figure and axes will be created. Default is None.
- df
- Returns:
matplotlib.axes.Axes
A Matplotlib Axes object with the Pen’s Parade plot.