@@ -3151,23 +3151,82 @@ def pie(self, y=None, **kwds):
3151
3151
3152
3152
def scatter (self , x , y , s = None , c = None , ** kwds ):
3153
3153
"""
3154
- Scatter plot
3154
+ Create a scatter plot with varying marker point size and color.
3155
+
3156
+ The coordinates of each point are defined by two dataframe columns and
3157
+ filled circles are used to represent each point. This kind of plot is
3158
+ useful to see complex correlations between two variables. Points could
3159
+ be for instance natural 2D coordinates like longitude and latitude in
3160
+ a map or, in general, any pair of metrics that can be plotted against
3161
+ each other.
3155
3162
3156
3163
Parameters
3157
3164
----------
3158
- x, y : label or position, optional
3159
- Coordinates for each point.
3165
+ x : int or str
3166
+ The column name or column position to be used as horizontal
3167
+ coordinates for each point.
3168
+ y : int or str
3169
+ The column name or column position to be used as vertical
3170
+ coordinates for each point.
3160
3171
s : scalar or array_like, optional
3161
- Size of each point.
3162
- c : label or position, optional
3163
- Color of each point.
3164
- `**kwds` : optional
3165
- Additional keyword arguments are documented in
3166
- :meth:`pandas.DataFrame.plot`.
3172
+ The size of each point. Possible values are:
3173
+
3174
+ - A single scalar so all points have the same size.
3175
+
3176
+ - A sequence of scalars, which will be used for each point's size
3177
+ recursively. For instance, when passing [2,14] all points size
3178
+ will be either 2 or 14, alternatively.
3179
+
3180
+ c : str, int or array_like, optional
3181
+ The color of each point. Possible values are:
3182
+
3183
+ - A single color string referred to by name, RGB or RGBA code,
3184
+ for instance 'red' or '#a98d19'.
3185
+
3186
+ - A sequence of color strings referred to by name, RGB or RGBA
3187
+ code, which will be used for each point's color recursively. For
3188
+ intance ['green','yellow'] all points will be filled in green or
3189
+ yellow, alternatively.
3190
+
3191
+ - A column name or position whose values will be used to color the
3192
+ marker points according to a colormap.
3193
+
3194
+ **kwds
3195
+ Keyword arguments to pass on to :meth:`pandas.DataFrame.plot`.
3167
3196
3168
3197
Returns
3169
3198
-------
3170
3199
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
3200
+
3201
+ See Also
3202
+ --------
3203
+ matplotlib.pyplot.scatter : scatter plot using multiple input data
3204
+ formats.
3205
+
3206
+ Examples
3207
+ --------
3208
+ Let's see how to draw a scatter plot using coordinates from the values
3209
+ in a DataFrame's columns.
3210
+
3211
+ .. plot::
3212
+ :context: close-figs
3213
+
3214
+ >>> df = pd.DataFrame([[5.1, 3.5, 0], [4.9, 3.0, 0], [7.0, 3.2, 1],
3215
+ ... [6.4, 3.2, 1], [5.9, 3.0, 2]],
3216
+ ... columns=['length', 'width', 'species'])
3217
+ >>> ax1 = df.plot.scatter(x='length',
3218
+ ... y='width',
3219
+ ... c='DarkBlue')
3220
+
3221
+ And now with the color determined by a column as well.
3222
+
3223
+ .. plot::
3224
+ :context: close-figs
3225
+
3226
+ >>> ax2 = df.plot.scatter(x='length',
3227
+ ... y='width',
3228
+ ... c='species',
3229
+ ... colormap='viridis')
3171
3230
"""
3172
3231
return self (kind = 'scatter' , x = x , y = y , c = c , s = s , ** kwds )
3173
3232
0 commit comments