or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

categorical-plots.mdcolor-palettes.mddistribution-plots.mdgrid-plots.mdindex.mdinteractive-widgets.mdmatrix-plots.mdobjects-interface.mdrelational-plots.mdstyling-themes.mdutilities.md

categorical-plots.mddocs/

0

# Categorical Plots

1

2

Visualize distributions and statistical summaries for categorical data using strip plots, swarm plots, box plots, violin plots, bar plots, and count plots. These functions reveal patterns across categorical groups and provide statistical insights.

3

4

## Capabilities

5

6

### Figure-level Categorical Plotting

7

8

Create multi-panel figures with categorical plots across subsets of data.

9

10

```python { .api }

11

def catplot(

12

data,

13

*,

14

x=None,

15

y=None,

16

hue=None,

17

row=None,

18

col=None,

19

col_wrap=None,

20

estimator="mean",

21

errorbar=("ci", 95),

22

n_boot=1000,

23

seed=None,

24

order=None,

25

hue_order=None,

26

row_order=None,

27

col_order=None,

28

kind="strip",

29

height=5,

30

aspect=1,

31

orient=None,

32

color=None,

33

palette=None,

34

hue_norm=None,

35

legend="auto",

36

legend_out=True,

37

sharex=True,

38

sharey=True,

39

margin_titles=False,

40

facet_kws=None,

41

**kwargs

42

):

43

"""

44

Figure-level interface for drawing categorical plots onto a FacetGrid.

45

46

Parameters:

47

- data: DataFrame, dict, or array of data

48

- x, y: str, names of variables in data

49

- hue: str, grouping variable for color mapping

50

- row, col: str, variables for faceting into subplots

51

- kind: str, plot type ("strip", "swarm", "box", "violin", "boxen", "point", "bar", "count")

52

- estimator: str or callable, statistical function for bar/point plots

53

- errorbar: str or tuple, error bar representation method

54

- height: float, height of each facet in inches

55

- aspect: float, aspect ratio of each facet

56

57

Returns:

58

FacetGrid object

59

"""

60

```

61

62

### Strip Plots

63

64

Draw categorical scatter plots with non-overlapping points.

65

66

```python { .api }

67

def stripplot(

68

data=None,

69

*,

70

x=None,

71

y=None,

72

hue=None,

73

order=None,

74

hue_order=None,

75

orient=None,

76

color=None,

77

palette=None,

78

size=5,

79

edgecolor="gray",

80

linewidth=0,

81

hue_norm=None,

82

native_scale=False,

83

formatter=None,

84

legend="auto",

85

ax=None,

86

**kwargs

87

):

88

"""

89

Draw a scatterplot where one variable is categorical.

90

91

Parameters:

92

- data: DataFrame, dict, or array of data

93

- x, y: str or array-like, input data variables

94

- hue: str, grouping variable for color mapping

95

- order: list, order for categorical levels

96

- size: float, marker size

97

- edgecolor: str, marker edge color

98

- native_scale: bool, use native scale for numeric categories

99

100

Returns:

101

matplotlib Axes object

102

"""

103

```

104

105

### Swarm Plots

106

107

Draw categorical scatter plots with adjusted point positions to avoid overlap.

108

109

```python { .api }

110

def swarmplot(

111

data=None,

112

*,

113

x=None,

114

y=None,

115

hue=None,

116

order=None,

117

hue_order=None,

118

orient=None,

119

color=None,

120

palette=None,

121

size=5,

122

edgecolor="gray",

123

linewidth=0,

124

hue_norm=None,

125

native_scale=False,

126

formatter=None,

127

legend="auto",

128

warn_thresh=0.05,

129

ax=None,

130

**kwargs

131

):

132

"""

133

Draw a categorical scatterplot with points adjusted to be non-overlapping.

134

135

Parameters:

136

- data: DataFrame, dict, or array of data

137

- x, y: str or array-like, input data variables

138

- hue: str, grouping variable for color mapping

139

- size: float, marker size

140

- warn_thresh: float, threshold for warning about point overlap

141

142

Returns:

143

matplotlib Axes object

144

"""

145

```

146

147

### Box Plots

148

149

Show distributions with quartiles, medians, and outliers.

150

151

```python { .api }

152

def boxplot(

153

data=None,

154

*,

155

x=None,

156

y=None,

157

hue=None,

158

order=None,

159

hue_order=None,

160

orient=None,

161

color=None,

162

palette=None,

163

saturation=0.75,

164

fill=True,

165

dodge="auto",

166

width=0.8,

167

gap=0,

168

whis=1.5,

169

linecolor="auto",

170

linewidth=None,

171

boxprops=None,

172

whiskerprops=None,

173

capprops=None,

174

medianprops=None,

175

flierprops=None,

176

hue_norm=None,

177

native_scale=False,

178

formatter=None,

179

legend="auto",

180

ax=None,

181

**kwargs

182

):

183

"""

184

Draw a box plot to show distributions with respect to categories.

185

186

Parameters:

187

- data: DataFrame, dict, or array of data

188

- x, y: str or array-like, input data variables

189

- hue: str, grouping variable for color mapping

190

- dodge: bool or "auto", separate hue levels along categorical axis

191

- width: float, width of boxes

192

- whis: float, whisker length as multiple of IQR

193

- boxprops, whiskerprops, etc.: dict, styling properties

194

195

Returns:

196

matplotlib Axes object

197

"""

198

```

199

200

### Violin Plots

201

202

Combine box plots with kernel density estimation to show full distributions.

203

204

```python { .api }

205

def violinplot(

206

data=None,

207

*,

208

x=None,

209

y=None,

210

hue=None,

211

order=None,

212

hue_order=None,

213

orient=None,

214

color=None,

215

palette=None,

216

saturation=0.75,

217

fill=True,

218

dodge="auto",

219

width=0.8,

220

gap=0,

221

inner="box",

222

split=False,

223

linecolor="auto",

224

linewidth=None,

225

cut=2,

226

gridsize=100,

227

bw_method="scott",

228

bw_adjust=1,

229

density_norm="area",

230

common_norm=False,

231

hue_norm=None,

232

formatter=None,

233

legend="auto",

234

ax=None,

235

**kwargs

236

):

237

"""

238

Draw a combination of boxplot and kernel density estimation.

239

240

Parameters:

241

- data: DataFrame, dict, or array of data

242

- x, y: str or array-like, input data variables

243

- hue: str, grouping variable for color mapping

244

- inner: str, representation inside violins ("box", "quart", "point", "stick", None)

245

- split: bool, split violins when hue nesting

246

- cut: float, distance to extend density beyond data extremes

247

- bw_method: str or scalar, bandwidth estimation method

248

249

Returns:

250

matplotlib Axes object

251

"""

252

```

253

254

### Enhanced Box Plots

255

256

Draw enhanced box plots optimized for larger datasets.

257

258

```python { .api }

259

def boxenplot(

260

data=None,

261

*,

262

x=None,

263

y=None,

264

hue=None,

265

order=None,

266

hue_order=None,

267

orient=None,

268

color=None,

269

palette=None,

270

saturation=0.75,

271

fill=True,

272

dodge="auto",

273

width=0.8,

274

gap=0,

275

linecolor=None,

276

linewidth=None,

277

width_method="exponential",

278

k_depth="tukey",

279

outlier_prop=0.007,

280

trust_alpha=0.05,

281

showfliers=True,

282

hue_norm=None,

283

native_scale=False,

284

formatter=None,

285

legend="auto",

286

ax=None,

287

**kwargs

288

):

289

"""

290

Draw an enhanced box plot for larger datasets.

291

292

Parameters:

293

- data: DataFrame, dict, or array of data

294

- x, y: str or array-like, input data variables

295

- hue: str, grouping variable for color mapping

296

- k_depth: str or int, number of boxes to draw

297

- outlier_prop: float, proportion of data as outliers

298

- showfliers: bool, whether to show outliers

299

300

Returns:

301

matplotlib Axes object

302

"""

303

```

304

305

### Point Plots

306

307

Show point estimates and confidence intervals with connecting lines.

308

309

```python { .api }

310

def pointplot(

311

data=None,

312

*,

313

x=None,

314

y=None,

315

hue=None,

316

order=None,

317

hue_order=None,

318

estimator="mean",

319

errorbar=("ci", 95),

320

n_boot=1000,

321

seed=None,

322

orient=None,

323

color=None,

324

palette=None,

325

markers="o",

326

linestyles="-",

327

dodge=False,

328

join=True,

329

scale=1,

330

hue_norm=None,

331

native_scale=False,

332

formatter=None,

333

legend="auto",

334

capsize=0,

335

err_kws=None,

336

ax=None,

337

**kwargs

338

):

339

"""

340

Show point estimates and confidence intervals using scatter plot glyphs.

341

342

Parameters:

343

- data: DataFrame, dict, or array of data

344

- x, y: str or array-like, input data variables

345

- hue: str, grouping variable for color mapping

346

- estimator: str or callable, statistical function

347

- errorbar: str or tuple, error bar representation method

348

- markers: str or list, marker styles

349

- linestyles: str or list, line styles for connections

350

- join: bool, connect points with lines

351

- scale: float, scaling factor for elements

352

353

Returns:

354

matplotlib Axes object

355

"""

356

```

357

358

### Bar Plots

359

360

Show point estimates and confidence intervals as rectangular bars.

361

362

```python { .api }

363

def barplot(

364

data=None,

365

*,

366

x=None,

367

y=None,

368

hue=None,

369

order=None,

370

hue_order=None,

371

estimator="mean",

372

errorbar=("ci", 95),

373

n_boot=1000,

374

seed=None,

375

orient=None,

376

color=None,

377

palette=None,

378

saturation=0.75,

379

fill=True,

380

hue_norm=None,

381

width=0.8,

382

dodge="auto",

383

gap=0,

384

log_scale=None,

385

native_scale=False,

386

formatter=None,

387

legend="auto",

388

capsize=0,

389

err_kws=None,

390

ax=None,

391

**kwargs

392

):

393

"""

394

Show point estimates and confidence intervals as rectangular bars.

395

396

Parameters:

397

- data: DataFrame, dict, or array of data

398

- x, y: str or array-like, input data variables

399

- hue: str, grouping variable for color mapping

400

- estimator: str or callable, statistical function

401

- errorbar: str or tuple, error bar representation method

402

- width: float, width of bars

403

- dodge: bool or "auto", separate hue levels

404

- capsize: float, cap width for error bars

405

406

Returns:

407

matplotlib Axes object

408

"""

409

```

410

411

### Count Plots

412

413

Show counts of observations in categorical bins using bars.

414

415

```python { .api }

416

def countplot(

417

data=None,

418

*,

419

x=None,

420

y=None,

421

hue=None,

422

order=None,

423

hue_order=None,

424

orient=None,

425

color=None,

426

palette=None,

427

saturation=0.75,

428

fill=True,

429

hue_norm=None,

430

stat="count",

431

width=0.8,

432

dodge="auto",

433

gap=0,

434

log_scale=None,

435

native_scale=False,

436

formatter=None,

437

legend="auto",

438

ax=None,

439

**kwargs

440

):

441

"""

442

Show the counts of observations in each categorical bin using bars.

443

444

Parameters:

445

- data: DataFrame, dict, or array of data

446

- x, y: str or array-like, input data variables (one should be categorical)

447

- hue: str, grouping variable for color mapping

448

- stat: str, statistic to compute ("count" or "percent")

449

- width: float, width of bars

450

- dodge: bool or "auto", separate hue levels

451

452

Returns:

453

matplotlib Axes object

454

"""

455

```

456

457

## Usage Examples

458

459

### Strip Plot

460

461

```python

462

import seaborn as sns

463

import matplotlib.pyplot as plt

464

465

tips = sns.load_dataset("tips")

466

467

# Basic strip plot

468

sns.stripplot(data=tips, x="day", y="total_bill")

469

plt.show()

470

```

471

472

### Box Plot with Grouping

473

474

```python

475

# Box plot with hue grouping

476

sns.boxplot(data=tips, x="day", y="total_bill", hue="smoker")

477

plt.show()

478

```

479

480

### Violin Plot

481

482

```python

483

# Violin plot showing full distributions

484

sns.violinplot(data=tips, x="day", y="total_bill", inner="box")

485

plt.show()

486

```

487

488

### Bar Plot with Confidence Intervals

489

490

```python

491

# Bar plot showing means with confidence intervals

492

sns.barplot(data=tips, x="day", y="total_bill", estimator="mean")

493

plt.show()

494

```

495

496

### Multi-Panel Categorical Plot

497

498

```python

499

# Create subplots by smoker status

500

sns.catplot(

501

data=tips,

502

x="day", y="total_bill",

503

col="smoker", kind="box"

504

)

505

plt.show()

506

```