verticapy.vDataFrame.contour#
- vDataFrame.contour(columns: str | list[str], func: Callable | str, nbins: int = 100, chart: PlottingBase | TableSample | Axes | mFigure | Highchart | Highstock | Figure | None = None, **style_kwargs) PlottingBase | TableSample | Axes | mFigure | Highchart | Highstock | Figure #
Draws the contour plot of the input function using two input vDataColumns.
Parameters#
- columns: SQLColumns
List of the vDataColumns names. The list must have two elements.
- func: function / str
Function used to compute the contour score. It can also be a SQL expression.
- nbins: int, optional
Number of bins used to discretize the two input numerical vDataColumns.
- chart: PlottingObject, optional
The chart object to plot on.
- **style_kwargs
Any optional parameter to pass to the plotting functions.
Returns#
- obj
Plotting Object.
Examples#
Note
The below example is a very basic one. For other more detailed examples and customization options, please see Contour Plot
Let’s begin by importing VerticaPy.
import verticapy as vp
Let’s also import numpy to create a dataset.
import numpy as np
We can create a variable
N
to fix the size:N = 30
For contour plots, we also need a function to apply:
def f(x, y): return x ** 2 - y + 1
Let’s generate a dataset using the following data.
data = vp.vDataFrame( { "x": np.random.normal(5, 1, N), "y": np.random.normal(8, 1.5, N), } )
Below is an examples of one type of contour plots:
Contour Plot
data.contour(columns = ["x", "y"], func = f)