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.
The column name or column position to be used as horizontal coordinates for each point.
The column name or column position to be used as vertical coordinates for each point.
The size of each point. Possible values are:
A string with the name of the column to be used for markerâs size.
A single scalar so all points have the same size.
A sequence of scalars, which will be used for each pointâs size recursively. For instance, when passing [2,14] all points size will be either 2 or 14, alternatively.
The color of each point. Possible values are:
A single color string referred to by name, RGB or RGBA code, for instance âredâ or â#a98d19â.
A sequence of color strings referred to by name, RGB or RGBA code, which will be used for each pointâs color recursively. For instance [âgreenâ,âyellowâ] all points will be filled in green or yellow, alternatively.
A column name or position whose values will be used to color the marker points according to a colormap.
Keyword arguments to pass on to DataFrame.plot()
.
matplotlib.axes.Axes
or numpy.ndarray of them
The matplotlib axes containing the scatter plot.
Examples
Letâs see how to draw a scatter plot using coordinates from the values in a DataFrameâs columns.
>>> df = pd.DataFrame( ... [ ... [5.1, 3.5, 0], ... [4.9, 3.0, 0], ... [7.0, 3.2, 1], ... [6.4, 3.2, 1], ... [5.9, 3.0, 2], ... ], ... columns=["length", "width", "species"], ... ) >>> ax1 = df.plot.scatter(x="length", y="width", c="DarkBlue")
And now with the color determined by a column as well.
>>> ax2 = df.plot.scatter( ... x="length", y="width", c="species", colormap="viridis" ... )
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4