Visualization
This page contains documentation for the visualization functionality.
- density(pnl, column=None, probability=None)
Function for generating a kernel density estimate plot for a P&L / risk factor simulation.
- Parameters:
pnl (
DataFrame) – P&L / risk factor simulation with shape (S, I).column (
int) – Column number for the instrument / risk factor the plot should be generated for. Default: 0.probability (
Union[ndarray,dict]) – Probability vector with shape (S,) or a dictionary with two keys each pointing to a np.ndarray with shape (S,). Set to np.ones(S) / S by default.
- Return type:
Axes- Returns:
The matplotlib axes containing the plot.
- Raises:
TypeError – If column is not an integer.
ValueError – If probability is not a np.ndarray with shape (S,) or a dictionary with two keys each refering to a np.ndarray with shape (S,).
IndexError – If column is greater than the number of columns in pnl.
ValueError – If probability vector(s) contain any non-positive elements or the sum of all elements is not 1.
- joint_density(pnl, columns, probability=None, xlim=None, ylim=None)
Function for generating a joint kernel density estimate plot for a P&L / risk factor simulation.
- Parameters:
pnl (
DataFrame) – P&L / risk factor simulation with shape (S, I).columns (
list[int,int]) – Column number for the instrument / risk factors the plot should be generated for.probability (
Union[ndarray,dict]) – Probability vector with shape (S,) or a dictionary with two keys each pointing to a np.ndarray with shape (S,). Set to np.ones(S) / S by default.xlim (
list[float,float]) – Optional list containing the minimum and maximum value for the x-axis. Default: None.ylim (
list[float,float]) – Optional list containing the minimum and maximum value for the y-axis. Default: None.
- Return type:
JointGrid- Returns:
An object managing multiple subplots that correspond to joint and marginal axes for plotting a bivariate relationship or distribution.
- Raises:
TypeError – If columns is not a list of length two containing only integers.
ValueError – If probability is not an np.ndarray with shape (S,) or a dictionary with two keys each refering to an np.ndarray with shape (S,).
IndexError – If any column is greater than the number of columns in pnl.
ValueError – If probability vector(s) contain any non-positive elements or the sum of all elements is not 1.