or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

configuration-management.mddata-operations.mdframework-integrations.mdindex.mdperformance-utilities.mdstatistical-analysis.mdvisualization-plotting.md

visualization-plotting.mddocs/

0

# Visualization and Plotting

1

2

Comprehensive plotting functions for Bayesian analysis including diagnostic plots, distribution visualizations, model comparison plots, and posterior predictive checks. Support for multiple backends (Matplotlib, Bokeh, Plotly) with publication-quality output.

3

4

## Diagnostic Plots

5

6

### MCMC Chain Diagnostics

7

8

```python { .api }

9

def plot_trace(data: InferenceData, *, var_names: list = None, coords: dict = None, divergences: str = "auto", figsize: tuple = None, **kwargs):

10

"""

11

Plot MCMC trace plots to assess chain mixing and convergence.

12

13

Args:

14

data (InferenceData): MCMC inference data

15

var_names (list, optional): Variables to plot

16

coords (dict, optional): Coordinate specifications for multidimensional variables

17

divergences (str): How to display divergences ("auto", "bottom", "top", False)

18

figsize (tuple, optional): Figure size (width, height)

19

**kwargs: Additional plotting parameters

20

21

Returns:

22

matplotlib axes or bokeh figure depending on backend

23

"""

24

25

def plot_rank(data: InferenceData, *, var_names: list = None, coords: dict = None, ref_line: bool = True, **kwargs):

26

"""

27

Plot rank plots for MCMC diagnostics and convergence assessment.

28

29

Args:

30

data (InferenceData): MCMC inference data with multiple chains

31

var_names (list, optional): Variables to plot

32

coords (dict, optional): Coordinate specifications

33

ref_line (bool): Whether to show reference line for uniform distribution

34

**kwargs: Additional plotting parameters

35

36

Returns:

37

matplotlib axes or bokeh figure

38

"""

39

40

def plot_autocorr(data: InferenceData, *, var_names: list = None, coords: dict = None, max_lag: int = 100, **kwargs):

41

"""

42

Plot autocorrelation function for MCMC chains.

43

44

Args:

45

data (InferenceData): MCMC inference data

46

var_names (list, optional): Variables to plot

47

coords (dict, optional): Coordinate specifications

48

max_lag (int): Maximum lag to display (default 100)

49

**kwargs: Additional plotting parameters

50

51

Returns:

52

matplotlib axes or bokeh figure

53

"""

54

55

def plot_ess(data: InferenceData, *, var_names: list = None, coords: dict = None, kind: str = "local", **kwargs):

56

"""

57

Plot effective sample size diagnostics.

58

59

Args:

60

data (InferenceData): MCMC inference data

61

var_names (list, optional): Variables to plot

62

coords (dict, optional): Coordinate specifications

63

kind (str): Type of ESS plot ("local", "quantile", "evolution")

64

**kwargs: Additional plotting parameters

65

66

Returns:

67

matplotlib axes or bokeh figure

68

"""

69

70

def plot_mcse(data: InferenceData, *, var_names: list = None, coords: dict = None, kind: str = "local", **kwargs):

71

"""

72

Plot Monte Carlo standard error diagnostics.

73

74

Args:

75

data (InferenceData): MCMC inference data

76

var_names (list, optional): Variables to plot

77

coords (dict, optional): Coordinate specifications

78

kind (str): Type of MCSE plot ("local", "quantile", "evolution")

79

**kwargs: Additional plotting parameters

80

81

Returns:

82

matplotlib axes or bokeh figure

83

"""

84

85

def plot_bpv(data: InferenceData, *, kind: str = None, coords: dict = None, **kwargs):

86

"""

87

Plot Bayesian p-value for model checking.

88

89

Args:

90

data (InferenceData): Inference data with observed data and posterior predictive

91

kind (str, optional): Plot type ("t_stat", "u_value", "scatter")

92

coords (dict, optional): Coordinate specifications

93

**kwargs: Additional plotting parameters

94

95

Returns:

96

matplotlib axes or bokeh figure

97

"""

98

99

def plot_bf(bf, *, labels: list = None, ref_val: float = 0, **kwargs):

100

"""

101

Plot Bayes factor results.

102

103

Args:

104

bf: Bayes factor values or results dictionary

105

labels (list, optional): Labels for different comparisons

106

ref_val (float): Reference value for hypothesis (default 0)

107

**kwargs: Additional plotting parameters

108

109

Returns:

110

matplotlib axes or bokeh figure

111

"""

112

```

113

114

### HMC/NUTS Specific Diagnostics

115

116

```python { .api }

117

def plot_energy(data: InferenceData, *, figsize: tuple = None, **kwargs):

118

"""

119

Plot energy diagnostics for Hamiltonian Monte Carlo.

120

121

Args:

122

data (InferenceData): MCMC inference data with energy information

123

figsize (tuple, optional): Figure size

124

**kwargs: Additional plotting parameters

125

126

Returns:

127

matplotlib axes showing energy distribution and transitions

128

"""

129

```

130

131

### Usage Examples

132

133

```python

134

import arviz as az

135

136

# Load example data

137

idata = az.load_arviz_data("centered_eight")

138

139

# Basic trace plot

140

az.plot_trace(idata, var_names=["mu", "tau"])

141

142

# Rank plot for convergence diagnostics

143

az.plot_rank(idata, var_names=["mu", "tau"])

144

145

# Autocorrelation plot

146

az.plot_autocorr(idata, var_names=["mu"], max_lag=50)

147

148

# ESS evolution plot

149

az.plot_ess(idata, kind="evolution")

150

151

# Energy diagnostics (if HMC/NUTS data available)

152

az.plot_energy(idata)

153

```

154

155

## Distribution Plots

156

157

### Posterior Distributions

158

159

```python { .api }

160

def plot_posterior(data: InferenceData, *, var_names: list = None, coords: dict = None, figsize: tuple = None, kind: str = "kde", **kwargs):

161

"""

162

Plot posterior distributions with summary statistics.

163

164

Args:

165

data (InferenceData): Inference data

166

var_names (list, optional): Variables to plot

167

coords (dict, optional): Coordinate specifications

168

figsize (tuple, optional): Figure size

169

kind (str): Plot type ("kde", "hist")

170

**kwargs: Additional plotting parameters (hdi_prob, point_estimate, etc.)

171

172

Returns:

173

matplotlib axes or bokeh figure

174

"""

175

176

def plot_density(data: InferenceData, *, var_names: list = None, coords: dict = None, shade: float = 0.0, **kwargs):

177

"""

178

Plot kernel density estimation for continuous variables.

179

180

Args:

181

data (InferenceData): Inference data

182

var_names (list, optional): Variables to plot

183

coords (dict, optional): Coordinate specifications

184

shade (float): Shading for density curves (0.0 to 1.0)

185

**kwargs: Additional plotting parameters

186

187

Returns:

188

matplotlib axes or bokeh figure

189

"""

190

191

def plot_dist(values, *, kind: str = "kde", label: str = None, color: str = None, **kwargs):

192

"""

193

Plot generic distribution for array-like data.

194

195

Args:

196

values: Array-like data to plot

197

kind (str): Plot type ("kde", "hist", "ecdf")

198

label (str, optional): Label for legend

199

color (str, optional): Color specification

200

**kwargs: Additional plotting parameters

201

202

Returns:

203

matplotlib axes or bokeh figure

204

"""

205

206

def plot_kde(values, *, label: str = None, bw: str = "default", adaptive: bool = False, **kwargs):

207

"""

208

Plot kernel density estimation for raw values.

209

210

Args:

211

values: Array-like data for KDE

212

label (str, optional): Label for legend

213

bw (str): Bandwidth selection ("default", "scott", "silverman")

214

adaptive (bool): Whether to use adaptive bandwidth

215

**kwargs: Additional plotting parameters

216

217

Returns:

218

matplotlib axes or bokeh figure

219

"""

220

```

221

222

### Comparative Distribution Plots

223

224

```python { .api }

225

def plot_violin(data: InferenceData, *, var_names: list = None, coords: dict = None, quartiles: bool = True, **kwargs):

226

"""

227

Plot violin plots for posterior distributions.

228

229

Args:

230

data (InferenceData): Inference data

231

var_names (list, optional): Variables to plot

232

coords (dict, optional): Coordinate specifications

233

quartiles (bool): Whether to show quartile lines

234

**kwargs: Additional plotting parameters

235

236

Returns:

237

matplotlib axes or bokeh figure

238

"""

239

240

def plot_dist_comparison(comp_dict: dict, *, kind: str = "kde", figsize: tuple = None, **kwargs):

241

"""

242

Compare distributions from multiple sources.

243

244

Args:

245

comp_dict (dict): Dictionary of label -> data mappings

246

kind (str): Plot type ("kde", "hist", "ecdf")

247

figsize (tuple, optional): Figure size

248

**kwargs: Additional plotting parameters

249

250

Returns:

251

matplotlib axes or bokeh figure

252

"""

253

```

254

255

### Usage Examples

256

257

```python

258

# Posterior distribution plots

259

az.plot_posterior(idata, var_names=["mu", "tau"], hdi_prob=0.89)

260

261

# Density plots with shading

262

az.plot_density(idata, var_names=["mu"], shade=0.1)

263

264

# Violin plots

265

az.plot_violin(idata, var_names=["theta"])

266

267

# Compare posterior vs prior

268

comparison = {

269

"posterior": idata.posterior["mu"].values.flatten(),

270

"prior": idata.prior["mu"].values.flatten()

271

}

272

az.plot_dist_comparison(comparison, kind="kde")

273

```

274

275

## Summary and Forest Plots

276

277

```python { .api }

278

def plot_forest(data: InferenceData, *, var_names: list = None, coords: dict = None, combined: bool = False, hdi_prob: float = 0.94, **kwargs):

279

"""

280

Plot forest plots for parameter estimates with credible intervals.

281

282

Args:

283

data (InferenceData): Inference data

284

var_names (list, optional): Variables to plot

285

coords (dict, optional): Coordinate specifications

286

combined (bool): Whether to combine chains

287

hdi_prob (float): Probability for HDI intervals

288

**kwargs: Additional plotting parameters

289

290

Returns:

291

matplotlib axes or bokeh figure

292

"""

293

294

def plot_compare(comp_df: pd.DataFrame, *, insample_dev: bool = True, plot_ic_diff: bool = True, figsize: tuple = None, **kwargs):

295

"""

296

Plot model comparison results from az.compare().

297

298

Args:

299

comp_df (pd.DataFrame): Model comparison dataframe from az.compare()

300

insample_dev (bool): Whether to plot in-sample deviance

301

plot_ic_diff (bool): Whether to plot IC differences

302

figsize (tuple, optional): Figure size

303

**kwargs: Additional plotting parameters

304

305

Returns:

306

matplotlib axes or bokeh figure

307

"""

308

309

def plot_elpd(comp_df: pd.DataFrame, *, xlabels: bool = False, figsize: tuple = None, **kwargs):

310

"""

311

Plot expected log pointwise predictive density comparison.

312

313

Args:

314

comp_df (pd.DataFrame): Model comparison dataframe

315

xlabels (bool): Whether to show x-axis labels

316

figsize (tuple, optional): Figure size

317

**kwargs: Additional plotting parameters

318

319

Returns:

320

matplotlib axes or bokeh figure

321

"""

322

323

def plot_khat(khat_data, *, annotate: bool = True, threshold: float = 0.7, figsize: tuple = None, **kwargs):

324

"""

325

Plot Pareto k-hat diagnostic values from LOO-CV.

326

327

Args:

328

khat_data: Pareto k values (from az.loo())

329

annotate (bool): Whether to annotate problematic points

330

threshold (float): Threshold for problematic k values

331

figsize (tuple, optional): Figure size

332

**kwargs: Additional plotting parameters

333

334

Returns:

335

matplotlib axes or bokeh figure

336

"""

337

```

338

339

### Usage Examples

340

341

```python

342

# Forest plot with credible intervals

343

az.plot_forest(idata, var_names=["mu", "tau"], hdi_prob=0.89)

344

345

# Model comparison plot

346

model_dict = {"model1": idata1, "model2": idata2}

347

comp_df = az.compare(model_dict)

348

az.plot_compare(comp_df)

349

350

# LOO diagnostics

351

loo_result = az.loo(idata)

352

az.plot_khat(loo_result.pareto_k, threshold=0.7)

353

```

354

355

## Multivariate Plots

356

357

```python { .api }

358

def plot_pair(data: InferenceData, *, var_names: list = None, coords: dict = None, kind: str = "scatter", divergences: bool = False, **kwargs):

359

"""

360

Plot pairwise relationships between variables.

361

362

Args:

363

data (InferenceData): Inference data

364

var_names (list, optional): Variables to include in pairs plot

365

coords (dict, optional): Coordinate specifications

366

kind (str): Plot type ("scatter", "kde", "hexbin")

367

divergences (bool): Whether to highlight divergent transitions

368

**kwargs: Additional plotting parameters

369

370

Returns:

371

matplotlib axes grid

372

"""

373

374

def plot_parallel(data: InferenceData, *, var_names: list = None, coords: dict = None, norm_method: str = "normal", **kwargs):

375

"""

376

Plot parallel coordinate plot for multidimensional data.

377

378

Args:

379

data (InferenceData): Inference data

380

var_names (list, optional): Variables to plot

381

coords (dict, optional): Coordinate specifications

382

norm_method (str): Normalization method ("normal", "minmax", "rank")

383

**kwargs: Additional plotting parameters

384

385

Returns:

386

matplotlib axes or bokeh figure

387

"""

388

```

389

390

### Usage Examples

391

392

```python

393

# Pairwise scatter plot

394

az.plot_pair(idata, var_names=["mu", "tau", "theta"], kind="scatter")

395

396

# Parallel coordinates plot

397

az.plot_parallel(idata, var_names=["mu", "tau"], norm_method="minmax")

398

```

399

400

## Predictive Plots

401

402

```python { .api }

403

def plot_ppc(data: InferenceData, *, var_names: list = None, coords: dict = None, kind: str = "kde", num_pp_samples: int = 100, **kwargs):

404

"""

405

Plot posterior predictive checks comparing observed data to predictions.

406

407

Args:

408

data (InferenceData): Inference data with posterior_predictive and observed_data

409

var_names (list, optional): Variables to plot

410

coords (dict, optional): Coordinate specifications

411

kind (str): Plot type ("kde", "cumulative", "scatter")

412

num_pp_samples (int): Number of posterior predictive samples to show

413

**kwargs: Additional plotting parameters

414

415

Returns:

416

matplotlib axes or bokeh figure

417

"""

418

419

def plot_loo_pit(data: InferenceData, *, y: str = None, y_hat: str = None, ecdf: bool = False, **kwargs):

420

"""

421

Plot Leave-One-Out Probability Integral Transform for model checking.

422

423

Args:

424

data (InferenceData): Inference data

425

y (str, optional): Observed data variable name

426

y_hat (str, optional): Posterior predictive variable name

427

ecdf (bool): Whether to plot empirical CDF

428

**kwargs: Additional plotting parameters

429

430

Returns:

431

matplotlib axes or bokeh figure

432

"""

433

434

def plot_bpv(data: InferenceData, *, kind: str = "p_value", reference: float = None, **kwargs):

435

"""

436

Plot Bayesian p-value for posterior predictive checks.

437

438

Args:

439

data (InferenceData): Inference data

440

kind (str): Plot type ("p_value", "u_value")

441

reference (float, optional): Reference value for comparison

442

**kwargs: Additional plotting parameters

443

444

Returns:

445

matplotlib axes or bokeh figure

446

"""

447

```

448

449

### Usage Examples

450

451

```python

452

# Posterior predictive check

453

az.plot_ppc(idata, var_names=["y"], kind="kde", num_pp_samples=50)

454

455

# LOO-PIT diagnostic

456

az.plot_loo_pit(idata, y="y_obs", y_hat="y_pred")

457

458

# Bayesian p-value

459

az.plot_bpv(idata, kind="p_value")

460

```

461

462

## Specialized Plots

463

464

```python { .api }

465

def plot_hdi(data, *, hdi_prob: float = 0.94, color: str = "C0", circular: bool = False, **kwargs):

466

"""

467

Plot highest density interval regions.

468

469

Args:

470

data: Posterior samples or InferenceData

471

hdi_prob (float): Probability for HDI region

472

color (str): Color specification

473

circular (bool): Whether data is circular

474

**kwargs: Additional plotting parameters

475

476

Returns:

477

matplotlib axes or bokeh figure

478

"""

479

480

def plot_dot(data: InferenceData, *, var_names: list = None, coords: dict = None, **kwargs):

481

"""

482

Plot dot plots for discrete variables.

483

484

Args:

485

data (InferenceData): Inference data

486

var_names (list, optional): Variables to plot

487

coords (dict, optional): Coordinate specifications

488

**kwargs: Additional plotting parameters

489

490

Returns:

491

matplotlib axes or bokeh figure

492

"""

493

494

def plot_ecdf(data: InferenceData, *, var_names: list = None, coords: dict = None, rug: bool = False, **kwargs):

495

"""

496

Plot empirical cumulative distribution function.

497

498

Args:

499

data (InferenceData): Inference data

500

var_names (list, optional): Variables to plot

501

coords (dict, optional): Coordinate specifications

502

rug (bool): Whether to show rug plot

503

**kwargs: Additional plotting parameters

504

505

Returns:

506

matplotlib axes or bokeh figure

507

"""

508

509

def plot_ts(data: InferenceData, *, var_names: list = None, coords: dict = None, **kwargs):

510

"""

511

Plot time series data.

512

513

Args:

514

data (InferenceData): Inference data with time dimension

515

var_names (list, optional): Variables to plot

516

coords (dict, optional): Coordinate specifications

517

**kwargs: Additional plotting parameters

518

519

Returns:

520

matplotlib axes or bokeh figure

521

"""

522

```

523

524

### Regression and Model Plots

525

526

```python { .api }

527

def plot_lm(y: np.ndarray, x: np.ndarray, *, y_hat: np.ndarray = None, y_mean: bool = False, **kwargs):

528

"""

529

Plot linear model diagnostics and predictions.

530

531

Args:

532

y (np.ndarray): Observed response values

533

x (np.ndarray): Predictor values

534

y_hat (np.ndarray, optional): Predicted values

535

y_mean (bool): Whether to show mean predictions

536

**kwargs: Additional plotting parameters

537

538

Returns:

539

matplotlib axes or bokeh figure

540

"""

541

542

def plot_separation(y: np.ndarray, y_hat: np.ndarray, *, threshold: float = 0.5, **kwargs):

543

"""

544

Plot separation plot for binary classification models.

545

546

Args:

547

y (np.ndarray): True binary outcomes

548

y_hat (np.ndarray): Predicted probabilities

549

threshold (float): Classification threshold

550

**kwargs: Additional plotting parameters

551

552

Returns:

553

matplotlib axes or bokeh figure

554

"""

555

556

def plot_bf(bf_data, *, ref_val: float = 1.0, labels: list = None, **kwargs):

557

"""

558

Plot Bayes factor comparison.

559

560

Args:

561

bf_data: Bayes factor values

562

ref_val (float): Reference value for comparison

563

labels (list, optional): Labels for comparison

564

**kwargs: Additional plotting parameters

565

566

Returns:

567

matplotlib axes or bokeh figure

568

"""

569

```

570

571

### Usage Examples

572

573

```python

574

# HDI region plot

575

az.plot_hdi(idata.posterior["mu"], hdi_prob=0.89)

576

577

# ECDF plot

578

az.plot_ecdf(idata, var_names=["mu"], rug=True)

579

580

# Linear model plot

581

az.plot_lm(y_observed, x_data, y_hat=predictions)

582

583

# Separation plot for classification

584

az.plot_separation(binary_outcomes, predicted_probs)

585

```

586

587

## Bokeh Backend Integration

588

589

ArviZ provides specialized functions for Bokeh backend integration, enabling interactive plots in Jupyter environments and web applications.

590

591

### Data Conversion and Output

592

593

```python { .api }

594

def to_cds(data, *, var_names: list = None, coords: dict = None, **kwargs):

595

"""

596

Convert ArviZ data to Bokeh ColumnDataSource format.

597

598

Transforms InferenceData or array-like data into Bokeh's

599

ColumnDataSource format for interactive plotting.

600

601

Args:

602

data: ArviZ InferenceData or array-like data

603

var_names (list, optional): Variables to include in conversion

604

coords (dict, optional): Coordinate specifications

605

**kwargs: Additional conversion parameters

606

607

Returns:

608

bokeh.models.ColumnDataSource: Bokeh-compatible data source

609

"""

610

611

def output_notebook(*args, **kwargs):

612

"""

613

Configure Bokeh output for Jupyter notebook display.

614

615

Sets up Bokeh to display interactive plots inline in

616

Jupyter notebooks with proper widget support.

617

618

Args:

619

*args: Arguments passed to bokeh.io.output_notebook

620

**kwargs: Keyword arguments for notebook configuration

621

"""

622

623

def output_file(*args, **kwargs):

624

"""

625

Configure Bokeh output for HTML file generation.

626

627

Sets up Bokeh to save interactive plots as standalone

628

HTML files that can be shared or embedded.

629

630

Args:

631

*args: Arguments passed to bokeh.io.output_file

632

**kwargs: Keyword arguments for file output configuration

633

"""

634

635

def ColumnDataSource(*args, **kwargs):

636

"""

637

Create Bokeh ColumnDataSource for plotting.

638

639

Wrapper around Bokeh's ColumnDataSource that integrates

640

with ArviZ data structures and coordinate systems.

641

642

Args:

643

*args: Arguments passed to bokeh.models.ColumnDataSource

644

**kwargs: Keyword arguments for data source creation

645

646

Returns:

647

bokeh.models.ColumnDataSource: Data source for Bokeh plots

648

"""

649

```

650

651

### Layout Management

652

653

```python { .api }

654

def create_layout(ax, force_layout: bool = False):

655

"""

656

Create Bokeh layout from plot axes.

657

658

Converts Bokeh plot figures into proper layout structures

659

for multi-panel displays and dashboard creation.

660

661

Args:

662

ax: Bokeh figure or list of figures

663

force_layout (bool): Whether to force specific layout structure

664

665

Returns:

666

bokeh.layouts Layout object (row, column, or gridplot)

667

"""

668

669

def show_layout(ax, show: bool = True, force_layout: bool = False):

670

"""

671

Display Bokeh layout with proper formatting.

672

673

Handles the display of single figures or complex layouts

674

with appropriate sizing and interactive features.

675

676

Args:

677

ax: Bokeh figure or layout to display

678

show (bool): Whether to immediately show the plot

679

force_layout (bool): Whether to force layout structure

680

681

Returns:

682

Displayed Bokeh plot or layout

683

"""

684

```

685

686

### Usage Examples

687

688

```python

689

# Convert data for Bokeh plotting

690

cds = az.to_cds(idata, var_names=["mu", "tau"])

691

print(f"Data columns: {cds.column_names}")

692

693

# Set up notebook output

694

az.output_notebook()

695

696

# Create interactive plots with Bokeh backend

697

with az.rc_context({"plot.backend": "bokeh"}):

698

# Trace plot with interactive features

699

trace_fig = az.plot_trace(idata, var_names=["mu"])

700

701

# Posterior plot with hover tooltips

702

post_fig = az.plot_posterior(idata, var_names=["tau"])

703

704

# Create custom layout

705

layout = az.create_layout([trace_fig, post_fig])

706

az.show_layout(layout)

707

708

# Save interactive plot to file

709

az.output_file("interactive_analysis.html")

710

with az.rc_context({"plot.backend": "bokeh"}):

711

az.plot_pair(idata, var_names=["mu", "tau"])

712

713

# Create custom ColumnDataSource for advanced plotting

714

import bokeh.plotting as bp

715

716

custom_cds = az.ColumnDataSource({

717

'x': idata.posterior["mu"].values.flatten(),

718

'y': idata.posterior["tau"].values.flatten()

719

})

720

721

# Use with native Bokeh plotting

722

p = bp.figure(title="Custom Scatter Plot")

723

p.circle('x', 'y', source=custom_cds, alpha=0.6)

724

az.show_layout(p)

725

```

726

727

### Integration with Native Bokeh

728

729

```python

730

# Combine ArviZ and native Bokeh functionality

731

from bokeh.models import HoverTool

732

from bokeh.plotting import figure

733

734

# Create enhanced interactive plot

735

def create_enhanced_posterior_plot(idata, var_name="mu"):

736

# Convert to Bokeh data source

737

cds = az.to_cds(idata, var_names=[var_name])

738

739

# Create figure with tools

740

p = figure(

741

title=f"Posterior Distribution: {var_name}",

742

tools="pan,wheel_zoom,box_zoom,reset,save"

743

)

744

745

# Add hover tool

746

hover = HoverTool(tooltips=[

747

("Chain", "@chain"),

748

("Draw", "@draw"),

749

("Value", f"@{var_name}")

750

])

751

p.add_tools(hover)

752

753

# Plot data

754

p.circle(f'{var_name}_x', f'{var_name}_y', source=cds, alpha=0.6)

755

756

return p

757

758

# Use enhanced plotting

759

enhanced_plot = create_enhanced_posterior_plot(idata, "mu")

760

az.show_layout(enhanced_plot)

761

```

762

763

## Backend Configuration

764

765

ArviZ supports multiple plotting backends for different use cases:

766

767

```python

768

# Set backend for current session

769

az.rcParams["plot.backend"] = "matplotlib" # Default

770

az.rcParams["plot.backend"] = "bokeh" # Interactive

771

az.rcParams["plot.backend"] = "plotly" # Web-based interactive

772

773

# Use context manager for temporary backend changes

774

with az.rc_context({"plot.backend": "bokeh"}):

775

az.plot_trace(idata) # Uses Bokeh backend

776

```

777

778

Common plotting parameters available across functions:

779

- `figsize`: Figure size (width, height)

780

- `ax`: Matplotlib axes to plot on

781

- `backend_kwargs`: Backend-specific parameters

782

- `show`: Whether to display plot immediately