Kde1d.plot
- Kde1d.plot(self, xlim: object | None = None, ylim: object | None = None, grid_size: int = 200, show_zero_mass: bool = True) None
Generates a plot for the Kde1d object.
This method creates a line plot for continuous data, a point plot for discrete data, and handles zero-inflated data with special point marking at zero.
- Parameters:
xlim (tuple (default=None)) – The limits for the x axis. Automatically set if None.
ylim (tuple (default=None)) – The limits for the y axis. Automatically set if None.
grid_size (int (default=200)) – The number of grid points to use for continuous data.
show_zero_mass (bool (default=True)) – Whether to show the point mass at zero for zero-inflated data.
**kwargs – Additional keyword arguments passed to matplotlib plotting functions.
- Returns:
Nothing, the function generates a plot and shows it using matplotlib.
Usage
import pyvinecopulib as pv import numpy as np import matplotlib.pyplot as plt # Continuous data np.random.seed(123) x = np.random.beta(0.5, 2.0, 100) kde = pv.Kde1d() kde.fit(x) plt.figure(figsize=(10, 6)) kde.plot() # Discrete data x_discrete = np.random.poisson(3, 100) kde_discrete = pv.Kde1d(type="discrete") kde_discrete.fit(x_discrete) kde_discrete.plot() # Zero-inflated data x_zi = np.random.exponential(2, 100) x_zi[np.random.choice(100, 30, replace=False)] = 0 kde_zi = pv.Kde1d(xmin=0, type="zero-inflated") kde_zi.fit(x_zi) kde_zi.plot()