vDataFrame.scatter¶
In [ ]:
vDataFrame.scatter(columns: list,
catcol: str = "",
max_cardinality: int = 3,
cat_priority: list = [],
with_others: bool = True,
max_nb_points: int = 20000,
dimensions: tuple = None,
bbox: list = [],
img: str = "",
ax=None,
**style_kwds,)
Draws the scatter plot of the input vcolumns.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
columns | list | ❌ | List of two or three vColumns. |
catcol | str | ✓ | Categorical vColumn for labeling the data. |
max_cardinality | int | ✓ | Maximum number of distinct elements for 'catcol' to be used as categorical. The less frequent elements will be gathered together to create a new category: 'Others'. |
cat_priority | list | ✓ | List of the different categories to consider when labeling the data using the 'catcol' vColumn. The other categories will be filtered. |
with_others | bool | ✓ | If set to false and the cardinality of the vColumn 'catcol' is too big, then the less frequent elements will not be merged to another category and these elements will not be drawn. |
max_nb_points | int | ✓ | Maximum number of points to display. |
dimensions | tuple | ✓ | Tuple of two elements representing the IDs of the PCA's components. If empty and the number of input columns is greater than three, the first and second PCA will be drawn. |
bbox | list | ✓ | List of four elements to delimit the boundaries of the final plot. This list must be formatted like: [xmin, xmax, ymin, ymax] |
img | str | ✓ | Path to the background image. |
ax | Matplotlib axes object | ✓ | The axes to plot on. |
**style_kwds | any | ✓ | Any optional parameter to pass to the Matplotlib functions. |
In [1]:
from verticapy.datasets import load_iris
iris = load_iris()
display(iris)
In [2]:
iris.scatter(["SepalWidthCm", "SepalLengthCm"])
Out[2]:
In [3]:
# 2D Scatter Plot with catcol
iris.scatter(["PetalWidthCm", "PetalLengthCm"],
catcol = "Species")
Out[3]:
In [4]:
# 3D Scatter Plot
iris.scatter(["PetalWidthCm", "PetalLengthCm", "SepalLengthCm"],
catcol = "Species")
Out[4]:
In [5]:
# Iris setosa vs others
iris.scatter(["PetalWidthCm", "PetalLengthCm"],
catcol = "Species",
cat_priority = ["Iris-setosa"])
Out[5]:
In [6]:
# Only Iris setosa
iris.scatter(["PetalWidthCm", "PetalLengthCm"],
catcol = "Species",
cat_priority = ["Iris-setosa"],
with_others = False)
Out[6]:
In [7]:
from verticapy import *
from verticapy.datasets import load_world
# Africa Dataset
africa = vDataFrame("africa_education")
africa_world = load_world()
africa_world = africa_world[africa_world["continent"] == "Africa"]
ax = africa_world["geometry"].geo_plot(color = "white",
edgecolor='black',)
# displaying schools in Africa
africa.scatter(["lon", "lat"],
catcol = "country_long",
ax = ax,
with_others = False)
Out[7]:
In [9]:
# Scatter Plot will use PCA when the dimensions is too big
# Drawing PCA components 1 & 2
iris.scatter(["SepalWidthCm",
"SepalLengthCm",
"PetalLengthCm",
"PetalWidthCm",])
Out[9]:
In [10]:
# Drawing PCA components 1 & 3
iris.scatter(["SepalWidthCm",
"SepalLengthCm",
"PetalLengthCm",
"PetalWidthCm",],
catcol = "Species",
dimensions = (1, 3))
Out[10]:
See Also¶
| vDataFrame.pivot_table | Draws the pivot table of vColumns based on an aggregation. |
