Pandas DataFrame: plot.scatter() function
DataFrame.plot.scatter() function
The plot-scatter() function is used to create a scatter plot with varying marker point size and color.
The coordinates of each point are defined by two dataframe columns and filled circles are used to represent each point. This kind of plot is useful to see complex correlations between two variables. Points could be for instance natural 2D coordinates like longitude and latitude in a map or, in general, any pair of metrics that can be plotted against each other.
Syntax:
DataFrame.plot.scatter(self, x, y, s=None, c=None, **kwargs)
Parameters:
Name | Description | Type/Default Value | Required / Optional |
---|---|---|---|
x | The column name or column position to be used as horizontal coordinates for each point. | int or str | Required |
y | The column name or column position to be used as vertical coordinates for each point. | int or str | Required |
s | The size of each point. Possible values are:
|
scalar or array_like | Optional |
c | The color of each point. Possible values are:
|
str, int or array_like | Optional |
**kwds | Keyword arguments to pass on to DataFrame.plot(). | Required |
Returns: matplotlib.axes.Axes or numpy.ndarray of them
Example:
Download the Pandas DataFrame Notebooks from here.
Previous: DataFrame.plot.pie() function
Next: DataFrame.boxplot() function
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/pandas/dataframe/dataframe-plot-scatter.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics