@@ -271,220 +271,6 @@ def hist_frame(
271271 )
272272
273273
274- _boxplot_doc = """
275- Make a box plot from DataFrame columns.
276-
277- Make a box-and-whisker plot from DataFrame columns, optionally grouped
278- by some other columns. A box plot is a method for graphically depicting
279- groups of numerical data through their quartiles.
280- The box extends from the Q1 to Q3 quartile values of the data,
281- with a line at the median (Q2). The whiskers extend from the edges
282- of box to show the range of the data. By default, they extend no more than
283- `1.5 * IQR (IQR = Q3 - Q1)` from the edges of the box, ending at the farthest
284- data point within that interval. Outliers are plotted as separate dots.
285-
286- For further details see
287- Wikipedia's entry for `boxplot <https://en.wikipedia.org/wiki/Box_plot>`_.
288-
289- Parameters
290- ----------
291- %(data)s\
292- column : str or list of str, optional
293- Column name or list of names, or vector.
294- Can be any valid input to :meth:`pandas.DataFrame.groupby`.
295- by : str or array-like, optional
296- Column in the DataFrame to :meth:`pandas.DataFrame.groupby`.
297- One box-plot will be done per value of columns in `by`.
298- ax : object of class matplotlib.axes.Axes, optional
299- The matplotlib axes to be used by boxplot.
300- fontsize : float or str
301- Tick label font size in points or as a string (e.g., `large`).
302- rot : float, default 0
303- The rotation angle of labels (in degrees)
304- with respect to the screen coordinate system.
305- grid : bool, default True
306- Setting this to True will show the grid.
307- figsize : A tuple (width, height) in inches
308- The size of the figure to create in matplotlib.
309- layout : tuple (rows, columns), optional
310- For example, (3, 5) will display the subplots
311- using 3 rows and 5 columns, starting from the top-left.
312- return_type : {'axes', 'dict', 'both'} or None, default 'axes'
313- The kind of object to return. The default is ``axes``.
314-
315- * 'axes' returns the matplotlib axes the boxplot is drawn on.
316- * 'dict' returns a dictionary whose values are the matplotlib
317- Lines of the boxplot.
318- * 'both' returns a namedtuple with the axes and dict.
319- * when grouping with ``by``, a Series mapping columns to
320- ``return_type`` is returned.
321-
322- If ``return_type`` is `None`, a NumPy array
323- of axes with the same shape as ``layout`` is returned.
324- %(backend)s\
325-
326- **kwargs
327- All other plotting keyword arguments to be passed to
328- :func:`matplotlib.pyplot.boxplot`.
329-
330- Returns
331- -------
332- result
333- See Notes.
334-
335- See Also
336- --------
337- Series.plot.hist: Make a histogram.
338- matplotlib.pyplot.boxplot : Matplotlib equivalent plot.
339-
340- Notes
341- -----
342- The return type depends on the `return_type` parameter:
343-
344- * 'axes' : object of class matplotlib.axes.Axes
345- * 'dict' : dict of matplotlib.lines.Line2D objects
346- * 'both' : a namedtuple with structure (ax, lines)
347-
348- For data grouped with ``by``, return a Series of the above or a numpy
349- array:
350-
351- * :class:`~pandas.Series`
352- * :class:`~numpy.array` (for ``return_type = None``)
353-
354- Use ``return_type='dict'`` when you want to tweak the appearance
355- of the lines after plotting. In this case a dict containing the Lines
356- making up the boxes, caps, fliers, medians, and whiskers is returned.
357-
358- Examples
359- --------
360-
361- Boxplots can be created for every column in the dataframe
362- by ``df.boxplot()`` or indicating the columns to be used:
363-
364- .. plot::
365- :context: close-figs
366-
367- >>> np.random.seed(1234)
368- >>> df = pd.DataFrame(np.random.randn(10, 4),
369- ... columns=['Col1', 'Col2', 'Col3', 'Col4'])
370- >>> boxplot = df.boxplot(column=['Col1', 'Col2', 'Col3']) # doctest: +SKIP
371-
372- Boxplots of variables distributions grouped by the values of a third
373- variable can be created using the option ``by``. For instance:
374-
375- .. plot::
376- :context: close-figs
377-
378- >>> df = pd.DataFrame(np.random.randn(10, 2),
379- ... columns=['Col1', 'Col2'])
380- >>> df['X'] = pd.Series(['A', 'A', 'A', 'A', 'A',
381- ... 'B', 'B', 'B', 'B', 'B'])
382- >>> boxplot = df.boxplot(by='X')
383-
384- A list of strings (i.e. ``['X', 'Y']``) can be passed to boxplot
385- in order to group the data by combination of the variables in the x-axis:
386-
387- .. plot::
388- :context: close-figs
389-
390- >>> df = pd.DataFrame(np.random.randn(10, 3),
391- ... columns=['Col1', 'Col2', 'Col3'])
392- >>> df['X'] = pd.Series(['A', 'A', 'A', 'A', 'A',
393- ... 'B', 'B', 'B', 'B', 'B'])
394- >>> df['Y'] = pd.Series(['A', 'B', 'A', 'B', 'A',
395- ... 'B', 'A', 'B', 'A', 'B'])
396- >>> boxplot = df.boxplot(column=['Col1', 'Col2'], by=['X', 'Y'])
397-
398- The layout of boxplot can be adjusted giving a tuple to ``layout``:
399-
400- .. plot::
401- :context: close-figs
402-
403- >>> boxplot = df.boxplot(column=['Col1', 'Col2'], by='X',
404- ... layout=(2, 1))
405-
406- Additional formatting can be done to the boxplot, like suppressing the grid
407- (``grid=False``), rotating the labels in the x-axis (i.e. ``rot=45``)
408- or changing the fontsize (i.e. ``fontsize=15``):
409-
410- .. plot::
411- :context: close-figs
412-
413- >>> boxplot = df.boxplot(grid=False, rot=45, fontsize=15) # doctest: +SKIP
414-
415- The parameter ``return_type`` can be used to select the type of element
416- returned by `boxplot`. When ``return_type='axes'`` is selected,
417- the matplotlib axes on which the boxplot is drawn are returned:
418-
419- >>> boxplot = df.boxplot(column=['Col1', 'Col2'], return_type='axes')
420- >>> type(boxplot)
421- <class 'matplotlib.axes._axes.Axes'>
422-
423- When grouping with ``by``, a Series mapping columns to ``return_type``
424- is returned:
425-
426- >>> boxplot = df.boxplot(column=['Col1', 'Col2'], by='X',
427- ... return_type='axes')
428- >>> type(boxplot)
429- <class 'pandas.Series'>
430-
431- If ``return_type`` is `None`, a NumPy array of axes with the same shape
432- as ``layout`` is returned:
433-
434- >>> boxplot = df.boxplot(column=['Col1', 'Col2'], by='X',
435- ... return_type=None)
436- >>> type(boxplot)
437- <class 'numpy.ndarray'>
438- """
439-
440- _backend_doc = """\
441- backend : str, default None
442- Backend to use instead of the backend specified in the option
443- ``plotting.backend``. For instance, 'matplotlib'. Alternatively, to
444- specify the ``plotting.backend`` for the whole session, set
445- ``pd.options.plotting.backend``.
446- """
447-
448-
449- _bar_or_line_doc = """
450- Parameters
451- ----------
452- x : label or position, optional
453- Allows plotting of one column versus another. If not specified,
454- the index of the DataFrame is used.
455- y : label or position, optional
456- Allows plotting of one column versus another. If not specified,
457- all numerical columns are used.
458- color : str, array-like, or dict, optional
459- The color for each of the DataFrame's columns. Possible values are:
460-
461- - A single color string referred to by name, RGB or RGBA code,
462- for instance 'red' or '#a98d19'.
463-
464- - A sequence of color strings referred to by name, RGB or RGBA
465- code, which will be used for each column recursively. For
466- instance ['green','yellow'] each column's %(kind)s will be filled in
467- green or yellow, alternatively. If there is only a single column to
468- be plotted, then only the first color from the color list will be
469- used.
470-
471- - A dict of the form {column name : color}, so that each column will be
472- colored accordingly. For example, if your columns are called `a` and
473- `b`, then passing {'a': 'green', 'b': 'red'} will color %(kind)ss for
474- column `a` in green and %(kind)ss for column `b` in red.
475-
476- **kwargs
477- Additional keyword arguments are documented in
478- :meth:`DataFrame.plot`.
479-
480- Returns
481- -------
482- matplotlib.axes.Axes or np.ndarray of them
483- An ndarray is returned with one :class:`matplotlib.axes.Axes`
484- per column when ``subplots=True``.
485- """
486-
487-
488274def boxplot (
489275 data : DataFrame ,
490276 column : str | list [str ] | None = None ,
0 commit comments