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

relational-plots.mddocs/

0

# Relational Plots

1

2

Visualize statistical relationships between variables using scatter plots, line plots, and regression analysis. These functions support semantic mapping with color, size, and style to reveal patterns across different groups in your data.

3

4

## Capabilities

5

6

### Figure-level Relational Plotting

7

8

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

9

10

```python { .api }

11

def relplot(

12

data,

13

*,

14

x=None,

15

y=None,

16

hue=None,

17

size=None,

18

style=None,

19

units=None,

20

row=None,

21

col=None,

22

col_wrap=None,

23

row_order=None,

24

col_order=None,

25

palette=None,

26

hue_order=None,

27

hue_norm=None,

28

sizes=None,

29

size_order=None,

30

size_norm=None,

31

markers=None,

32

dashes=None,

33

style_order=None,

34

legend="auto",

35

kind="scatter",

36

height=5,

37

aspect=1,

38

facet_kws=None,

39

**kwargs

40

):

41

"""

42

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

43

44

Parameters:

45

- data: DataFrame, dict, or array of data

46

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

47

- hue: str, grouping variable for color mapping

48

- size: str, grouping variable for size mapping

49

- style: str, grouping variable for style mapping

50

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

51

- kind: str, either "scatter" or "line"

52

- height: float, height of each facet in inches

53

- aspect: float, aspect ratio of each facet

54

55

Returns:

56

FacetGrid object

57

"""

58

```

59

60

### Scatter Plots

61

62

Draw scatter plots with semantic groupings for exploring relationships between continuous variables.

63

64

```python { .api }

65

def scatterplot(

66

data=None,

67

*,

68

x=None,

69

y=None,

70

hue=None,

71

size=None,

72

style=None,

73

palette=None,

74

hue_order=None,

75

hue_norm=None,

76

sizes=None,

77

size_order=None,

78

size_norm=None,

79

markers=True,

80

style_order=None,

81

legend="auto",

82

ax=None,

83

**kwargs

84

):

85

"""

86

Draw a scatter plot with possibility of several semantic groupings.

87

88

Parameters:

89

- data: DataFrame, dict, or array of data

90

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

91

- hue: str, grouping variable for color mapping

92

- size: str, grouping variable for point sizes

93

- style: str, grouping variable for point markers

94

- palette: str or list, colors to use for hue levels

95

- sizes: tuple or dict, size range or mapping for size variable

96

- markers: bool or list, marker styles for style levels

97

- ax: matplotlib Axes, axes object to draw plot onto

98

99

Returns:

100

matplotlib Axes object

101

"""

102

```

103

104

### Line Plots

105

106

Draw line plots with semantic groupings for time series and ordered data visualization.

107

108

```python { .api }

109

def lineplot(

110

data=None,

111

*,

112

x=None,

113

y=None,

114

hue=None,

115

size=None,

116

style=None,

117

units=None,

118

weights=None,

119

palette=None,

120

hue_order=None,

121

hue_norm=None,

122

sizes=None,

123

size_order=None,

124

size_norm=None,

125

dashes=True,

126

markers=None,

127

style_order=None,

128

estimator="mean",

129

errorbar=("ci", 95),

130

n_boot=1000,

131

seed=None,

132

orient="x",

133

sort=True,

134

err_style="band",

135

err_kws=None,

136

legend="auto",

137

ci="deprecated",

138

ax=None,

139

**kwargs

140

):

141

"""

142

Draw a line plot with possibility of several semantic groupings.

143

144

Parameters:

145

- data: DataFrame, dict, or array of data

146

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

147

- hue: str, grouping variable for color mapping

148

- size: str, grouping variable for line width

149

- style: str, grouping variable for line style

150

- units: str, grouping variable for individual line segments

151

- weights: str, grouping variable for observation weights

152

- estimator: str or callable, statistical function for aggregation

153

- errorbar: str or tuple, error bar representation method

154

- sort: bool, whether to sort x variable

155

- err_style: str, "band" or "bars" for error representation

156

157

Returns:

158

matplotlib Axes object

159

"""

160

```

161

162

### Regression Plots

163

164

Visualize linear relationships with regression lines and confidence intervals.

165

166

```python { .api }

167

def regplot(

168

data=None,

169

*,

170

x=None,

171

y=None,

172

x_estimator=None,

173

x_bins=None,

174

x_ci="ci",

175

scatter=True,

176

fit_reg=True,

177

ci=95,

178

n_boot=1000,

179

units=None,

180

seed=None,

181

order=1,

182

logistic=False,

183

lowess=False,

184

robust=False,

185

logx=False,

186

x_partial=None,

187

y_partial=None,

188

truncate=True,

189

dropna=True,

190

x_jitter=None,

191

y_jitter=None,

192

label=None,

193

color=None,

194

marker="o",

195

scatter_kws=None,

196

line_kws=None,

197

ax=None,

198

**kwargs

199

):

200

"""

201

Plot data and a linear regression model fit.

202

203

Parameters:

204

- data: DataFrame, dict, or array of data

205

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

206

- x_estimator: callable, function for binning x variable

207

- scatter: bool, whether to draw scatter plot points

208

- fit_reg: bool, whether to fit regression line

209

- ci: int or None, confidence interval size

210

- order: int, polynomial order for regression

211

- logistic: bool, fit logistic regression

212

- lowess: bool, fit lowess smoother

213

- robust: bool, fit robust regression

214

- scatter_kws: dict, keyword arguments for scatter plot

215

- line_kws: dict, keyword arguments for regression line

216

217

Returns:

218

matplotlib Axes object

219

"""

220

```

221

222

### Multi-Panel Regression

223

224

Create regression plots across multiple subsets of data.

225

226

```python { .api }

227

def lmplot(

228

data,

229

*,

230

x=None,

231

y=None,

232

hue=None,

233

col=None,

234

row=None,

235

palette=None,

236

col_wrap=None,

237

height=5,

238

aspect=1,

239

markers="o",

240

sharex=None,

241

sharey=None,

242

hue_order=None,

243

col_order=None,

244

row_order=None,

245

legend=True,

246

legend_out=None,

247

x_estimator=None,

248

x_bins=None,

249

x_ci="ci",

250

scatter=True,

251

fit_reg=True,

252

ci=95,

253

n_boot=1000,

254

units=None,

255

seed=None,

256

order=1,

257

logistic=False,

258

lowess=False,

259

robust=False,

260

logx=False,

261

x_partial=None,

262

y_partial=None,

263

truncate=True,

264

x_jitter=None,

265

y_jitter=None,

266

scatter_kws=None,

267

line_kws=None,

268

facet_kws=None,

269

**kwargs

270

):

271

"""

272

Plot data and regression model fits across a FacetGrid.

273

274

Parameters:

275

- data: DataFrame

276

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

277

- hue: str, grouping variable for color mapping

278

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

279

- height: float, height of each facet in inches

280

- aspect: float, aspect ratio of each facet

281

- markers: str or list, marker styles for hue levels

282

- All regplot parameters are also accepted

283

284

Returns:

285

FacetGrid object

286

"""

287

```

288

289

### Residual Plots

290

291

Plot residuals of linear regression for model diagnostics.

292

293

```python { .api }

294

def residplot(

295

data=None,

296

*,

297

x=None,

298

y=None,

299

x_partial=None,

300

y_partial=None,

301

lowess=False,

302

order=1,

303

robust=False,

304

dropna=True,

305

label=None,

306

color=None,

307

scatter_kws=None,

308

line_kws=None,

309

ax=None,

310

**kwargs

311

):

312

"""

313

Plot the residuals of a linear regression.

314

315

Parameters:

316

- data: DataFrame, dict, or array of data

317

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

318

- x_partial, y_partial: str, variables to partial out

319

- lowess: bool, fit lowess smoother to residuals

320

- order: int, polynomial order for regression

321

- robust: bool, use robust regression

322

- scatter_kws: dict, keyword arguments for scatter plot

323

- line_kws: dict, keyword arguments for reference line

324

325

Returns:

326

matplotlib Axes object

327

"""

328

```

329

330

## Usage Examples

331

332

### Basic Scatter Plot

333

334

```python

335

import seaborn as sns

336

import matplotlib.pyplot as plt

337

338

# Load dataset

339

tips = sns.load_dataset("tips")

340

341

# Basic scatter plot

342

sns.scatterplot(data=tips, x="total_bill", y="tip")

343

plt.show()

344

```

345

346

### Scatter Plot with Grouping

347

348

```python

349

# Scatter plot with color grouping

350

sns.scatterplot(data=tips, x="total_bill", y="tip", hue="time", style="smoker")

351

plt.show()

352

```

353

354

### Multi-Panel Relational Plot

355

356

```python

357

# Create subplots by day of week

358

sns.relplot(

359

data=tips,

360

x="total_bill", y="tip",

361

col="day", hue="time",

362

kind="scatter"

363

)

364

plt.show()

365

```

366

367

### Line Plot with Confidence Intervals

368

369

```python

370

# Time series with error bands

371

flights = sns.load_dataset("flights")

372

sns.lineplot(data=flights, x="year", y="passengers")

373

plt.show()

374

```

375

376

### Regression Plot

377

378

```python

379

# Linear regression with confidence interval

380

sns.regplot(data=tips, x="total_bill", y="tip")

381

plt.show()

382

```