<jupyter_start><jupyter_text>Customizing Matplotlib: Configurations and Style Sheets<jupyter_code>import matplotlib.pyplot as plt
plt.style.use('classic')
import numpy as np

%matplotlib inline
x = np.random.randn(1000)
plt.hist(x);
# use a gray background
ax = plt.axes(axisbg='#E6E6E6')
ax.set_axisbelow(True)

# draw solid white grid lines
plt.grid(color='w', linestyle='solid')

# hide axis spines
for spine in ax.spines.values():
    spine.set_visible(False)
    
# hide top and right ticks
ax.xaxis.tick_bottom()
ax.yaxis.tick_left()

# lighten ticks and labels
ax.tick_params(colors='gray', direction='out')
for tick in ax.get_xticklabels():
    tick.set_color('gray')
for tick in ax.get_yticklabels():
    tick.set_color('gray')
    
# control face and edge color of histogram
ax.hist(x, edgecolor='#E6E6E6', color='#EE6666');
IPython_default = plt.rcParams.copy()
from matplotlib import cycler
colors = cycler('color',
                ['#EE6666', '#3388BB', '#9988DD',
                 '#EECC55', '#88BB44', '#FFBBBB'])
plt.rc('axes', facecolor='#E6E6E6', edgecolor='none',
       axisbelow=True, grid=True, prop_cycle=colors)
plt.rc('grid', color='w', linestyle='solid')
plt.rc('xtick', direction='out', color='gray')
plt.rc('ytick', direction='out', color='gray')
plt.rc('patch', edgecolor='#E6E6E6')
plt.rc('lines', linewidth=2)
plt.hist(x);
for i in range(4):
    plt.plot(np.random.rand(10))
plt.style.available[:5]
def hist_and_lines():
    np.random.seed(0)
    fig, ax = plt.subplots(1, 2, figsize=(11, 4))
    ax[0].hist(np.random.randn(1000))
    for i in range(3):
        ax[1].plot(np.random.rand(10))
    ax[1].legend(['a', 'b', 'c'], loc='lower left')
# reset rcParams
plt.rcParams.update(IPython_default);
hist_and_lines()
with plt.style.context('fivethirtyeight'):
    hist_and_lines()
with plt.style.context('ggplot'):
    hist_and_lines()
with plt.style.context('bmh'):
    hist_and_lines()
with plt.style.context('dark_background'):
    hist_and_lines()
with plt.style.context('grayscale'):
    hist_and_lines()
import seaborn
hist_and_lines()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1698382492863939, 'fraction_numerical': 0.028068506184586107, 'mean_word_length': 5.113372093023256, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '607703', 'license': 'MIT', 'n_tokens_mistral': 821, 'n_tokens_neox': 782, 'n_words': 156, 'path': 'code_listings/04.11-Settings-and-Stylesheets.ipynb', 'repo_name': 'minhpqn/PythonDataScienceHandbook', 'size': '2102'}