Price Plot
Price-band bubble distribution across categories.
x = category, y = price bands, bubble area proportional to the share of each group's products in a band. One row per product with a numeric price column (pandas only).
plot(df, value_col, group_col, bins, title=None, eyebrow=None, subtitle=None, x_label=None, y_label=None, legend_title=None, figsize=None, ax=None, source_text=None, move_legend_outside=False, **kwargs)
Plot a price-band bubble chart: categories on x, price bands on y.
Bubble area is proportional to the absolute share of each group's products in a band, so sizes stay comparable across groups. Y tick labels show each band as "lower - upper" to one decimal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Product-level frame (one row per product). |
required |
value_col
|
str
|
Numeric price/value column to bin. |
required |
group_col
|
str
|
Categorical grouping column (x-axis). |
required |
bins
|
int or list[float]
|
Number of equal-width bins, or custom boundaries. |
required |
title
|
str
|
Plot title. |
None
|
eyebrow
|
str
|
Uppercase label rendered above the title. |
None
|
subtitle
|
str
|
Supporting copy rendered below the title. |
None
|
x_label
|
str
|
X-axis label; omitted means no label. |
None
|
y_label
|
str
|
Y-axis label; omitted means no label. |
None
|
legend_title
|
str
|
Legend title. |
None
|
figsize
|
tuple[int, int]
|
Figure size, used only when ax is None. |
None
|
ax
|
Axes
|
Axes to plot on. |
None
|
source_text
|
str
|
Source attribution rendered at the bottom. |
None
|
move_legend_outside
|
bool
|
Move the legend outside the plot. |
False
|
**kwargs
|
Any
|
Forwarded to matplotlib scatter; s scales bubble area (default 2000) and edgecolor defaults to black. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If df is empty, value_col is not numeric, every row is missing value_col or group_col, or no data falls within the bins. |
KeyError
|
If value_col or group_col is not a column of df. |
TypeError
|
If bins is neither an int nor a list. |
Source code in openretailscience/plots/price.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |