<jupyter_start><jupyter_text>Complete guide to boxplot- Pandas doc: https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.boxplot.html- Matplotlib doc: https://matplotlib.org/api/_as_gen/matplotlib.pyplot.boxplot.htmlmatplotlib.pyplot.boxplot- Matplotlib customization doc: https://matplotlib.org/tutorials/introductory/customizing.html?highlight=flierprops  1. Configuration<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline

import warnings
warnings.filterwarnings("ignore")<jupyter_output><empty_output><jupyter_text>---  2. Data<jupyter_code>auto = pd.read_csv('auto-mpg.csv')
auto.head()
auto.tail()<jupyter_output><empty_output><jupyter_text>---  3. Pandas boxplot standard parameters`DataFrame.boxplot(column=None, by=None, ax=None, fontsize=None, rot=0, grid=True, figsize=None, layout=None, return_type=None, **kwds)`- ax: another plot- rot: text rotation- figsize, layout: tuple<jupyter_code>auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None)

# get rid of the automatic 'Boxplot grouped by group_by_column_name' title
plt.suptitle('')

# get rid of the title
plt.title('')
plt.ylabel('mpg')<jupyter_output><empty_output><jupyter_text>---  4. Matplotlib boxplot parameters`matplotlib.pyplot.boxplot(x, notch=None, sym=None, vert=None, whis=None, positions=None, widths=None, patch_artist=None, bootstrap=None, usermedians=None, conf_intervals=None, meanline=None, showmeans=None, showcaps=None, showbox=None, showfliers=None, boxprops=None, labels=None, flierprops=None, medianprops=None, meanprops=None, capprops=None, whiskerprops=None, manage_xticks=True, autorange=False, zorder=None, hold=None, data=None)`  a) Notched plot<jupyter_code>auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None, 
             notch=True)
plt.title('')
plt.ylabel('mpg')<jupyter_output><empty_output><jupyter_text>b) Outliers points symbol, flierprops<jupyter_code># Default
auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None, 
             sym=None)
plt.title('')
plt.ylabel('mpg')

# Don't show outlier points
auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None, 
             sym='')
plt.suptitle('Boxplot grouped by color (no outliers)')
plt.title('')
plt.ylabel('mpg')

# Change outlier point symbol
auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None, 
             sym='gD')
plt.suptitle('Boxplot grouped by color (different outliers symbols)')
plt.title('')
plt.ylabel('mpg')<jupyter_output><empty_output><jupyter_text>c) Horizontal boxplot<jupyter_code>auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None, 
             vert=False)
plt.title('')
plt.xlabel('mpg')
plt.ylabel('color')<jupyter_output><empty_output><jupyter_text>d) Whiskers<jupyter_code># Default
auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None, 
             whis=1.5)
plt.title('')
plt.ylabel('mpg')

# Specific percentile
auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None, 
             whis=[5,95])
plt.suptitle('Boxplot grouped by color (custom percentile)')
plt.title('')
plt.ylabel('mpg')<jupyter_output><empty_output><jupyter_text>e) bootstrap & usermedians & conf_intervals- https://matplotlib.org/gallery/statistics/boxplot_demo.htmlsphx-glr-gallery-statistics-boxplot-demo-py  f) Positions of categorical variable<jupyter_code># Default
auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None)
plt.title('')
plt.ylabel('mpg')

# Reordered positions
positions = [5,4,3,2,1]
auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None, 
             positions=positions)
plt.suptitle('Boxplot grouped by color (reversed order)')
plt.title('')
plt.ylabel('mpg')<jupyter_output><empty_output><jupyter_text>g) Width between boxes<jupyter_code># Default
auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None)
plt.title('')
plt.ylabel('mpg')

# Reordered positions
positions = [5,4,3,2,1]
auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None, 
             widths=0.75)
plt.suptitle('Boxplot grouped by color (different widths)')
plt.title('')
plt.ylabel('mpg')<jupyter_output><empty_output><jupyter_text>h) Type of artists<jupyter_code># Default
auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None)
plt.title('')
plt.ylabel('mpg')

# Reordered positions
positions = [5,4,3,2,1]
auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None, 
             patch_artist=True)
plt.suptitle('Boxplot grouped by color (different artist)')
plt.title('')
plt.ylabel('mpg')<jupyter_output><empty_output><jupyter_text>j) Labels- https://matplotlib.org/examples/statistics/boxplot_demo.html  k) Manage xticks<jupyter_code># Default
auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None)
plt.title('')
plt.ylabel('mpg')

# Reordered positions
auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None, 
             manage_xticks=False)
plt.suptitle('Boxplot grouped by color (auto-adjust xticks)')
plt.title('')
plt.ylabel('mpg')<jupyter_output><empty_output><jupyter_text>l) Autorange- https://github.com/matplotlib/matplotlib/issues/5331/- https://github.com/matplotlib/matplotlib/pull/5343<jupyter_code># Default
auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None)
plt.title('')
plt.ylabel('mpg')

# Reordered positions
auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None, 
             autorange=True)
plt.suptitle('Boxplot grouped by color (autorange)')
plt.title('')
plt.ylabel('mpg')<jupyter_output><empty_output><jupyter_text>m) Mean line<jupyter_code># Default
auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None)
plt.title('')
plt.ylabel('mpg')

# Reordered positions
auto.boxplot(column='mpg', by='color', ax=None, fontsize=12, rot=0, grid=True, 
             figsize=None, layout=None, return_type=None, 
             meanline=True, showmeans=True)
plt.suptitle('Boxplot grouped by color (different mean line)')
plt.title('')
plt.ylabel('mpg')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15764546684709066, 'fraction_numerical': 0.012990527740189444, 'mean_word_length': 5.534924845269673, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '407388', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 2810, 'n_tokens_neox': 2656, 'n_words': 461, 'path': 'visualizations/boxplot.ipynb', 'repo_name': 'shawnngtq/data-science', 'size': '7390'}