<jupyter_start><jupyter_text>plt-mpl<jupyter_code>import numpy as np

import matplotlib.pyplot as plt

%matplotlib inline<jupyter_output><empty_output><jupyter_text>Some "Black Magic" Tricks<jupyter_code>plt.rcParams['font.size'] = 20
plt.rcParams['axes.prop_cycle'] = plt.cycler(
    color=['hotpink', '#008000']
)<jupyter_output><empty_output><jupyter_text>Plots<jupyter_code>x = np.linspace(0, 1, 10)
y = 2 * np.sin(x)<jupyter_output><empty_output><jupyter_text>One<jupyter_code>fig, ax = plt.subplots(figsize=(10, 10))


ax.plot(
    x, y, 
    linewidth=5,
    label='2 sin(x)',
    marker='s',
    markersize=20,
    linestyle='-.'
)


plt.xlabel('X')
plt.ylabel('Y')

plt.legend(loc='center right')

plt.minorticks_on()
plt.grid(which='both', axis='x', zorder=10)

fig.savefig('plot.svg')

plt.show()<jupyter_output><empty_output><jupyter_text>Two<jupyter_code>fig, ax = plt.subplots(figsize=(10, 10))


ax.plot(
    x, y, 
    linewidth=5,
    label='2 sin(x)',
    zorder=0
)

ax.plot(
    x, -y, 
    linewidth=5,
    label='-2 sin(x)',
    zorder=0
)


plt.xlabel('X')
plt.ylabel('Y')

plt.legend(loc='center right')


plt.minorticks_on()
plt.grid(which='both', axis='x', zorder=10)

plt.show()<jupyter_output><empty_output><jupyter_text>Many<jupyter_code>fig, ax = plt.subplots(figsize=(20, 10))


for shift in np.arange(0, 101):
    plt.plot(
        x + shift/100, y, 
        linewidth=5,
    )


plt.xlabel('X')
plt.ylabel('Y')

plt.grid()

plt.show()<jupyter_output><empty_output><jupyter_text>Subplots<jupyter_code>fig, axes = plt.subplots(
    nrows=2,
    ncols=1,
    figsize=(20, 10)
)


ax = axes[0]

ax.plot(
    x, y, 
    linewidth=5,
    color='green'
)

ax.set_xlim(0, 1.1)
ax.set_xticklabels([])

ax.grid()


ax = axes[1]

ax.plot(
    x + 0.1, -2 * y + 1, 
    linewidth=5,
)

ax.set_xlim(0, 1.1)


plt.tight_layout(pad=0.01)
plt.grid()

ax.set_xlabel('X')


plt.show()<jupyter_output><empty_output><jupyter_text>Twins<jupyter_code>fig, ax = plt.subplots(
    nrows=1,
    ncols=1,
    figsize=(20, 10)
)


ax.plot(
    x, y, 
    linewidth=5,
    color='green'
)

ax.set_ylabel('Y', color='green')


ax2 = ax.twinx()

ax2.plot(
    x + 0.1, -2 * y + 1,
    linewidth=5,
    color='hotpink'
)

ax2.set_ylabel('Y', color='hotpink')
ax2.tick_params(axis='y', colors='hotpink')

plt.show()<jupyter_output><empty_output><jupyter_text>Scatter<jupyter_code>fig, ax = plt.subplots(
    nrows=1,
    ncols=1,
    figsize=(20, 10)
)


ax.scatter(
    x, y,
    s=400,
    color='green',
    zorder=10
)

ax.plot(
    [0], [0],
    marker='s',
    markersize=20,
    color='hotpink'
)


plt.grid()
plt.show()
fig, ax = plt.subplots(
    nrows=1,
    ncols=1,
    figsize=(20, 10)
)

plt.hlines(1, 0, 10)
plt.vlines(5, 0, 2, color='green')

plt.show()
_ = plt.hist([1, 1, 2, 3, 5, 5, 5, 5])
_ = plt.pie([1, 2])<jupyter_output><empty_output><jupyter_text>Pandas Section<jupyter_code>import os
import warnings

import pandas as pd
import seaborn as sns

warnings.filterwarnings('ignore')

# Graphics in retina format are more sharp and legible
%config InlineBackend.figure_format = 'retina'
# https://github.com/Yorko/mlcourse.ai/blob/main/data/beauty.csv

DATA_PATH = os.path.join('data', 'beauty.csv')
pd.read_csv(DATA_PATH, nrows=2, sep=';')
df = pd.read_csv(DATA_PATH, sep=';')

df.head()<jupyter_output><empty_output><jupyter_text>Examples<jupyter_code>obj = df['wage'].hist(figsize=(6, 4), bins=100)
_ = sns.distplot(df['wage'], bins=10)
_ = df[['wage', 'exper']].hist(figsize=(10, 4), bins=20)
_ = sns.countplot(x='female', data=df)
_ = sns.countplot(y='female', data=df)
_ = sns.countplot(x='female', hue='looks', data=df)
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(12, 4))

sns.countplot(x='female', data=df, ax=axes[0])
sns.countplot(x='looks', data=df, ax=axes[1])
df.groupby('female')['wage'].count()
type(df.groupby('female')['wage'].count())
female_counts = df.groupby('female')['wage'].count()

sex_id_to_name = {0: 'male', 1: 'female'}

_ = plt.pie(
    female_counts,
    labels=[sex_id_to_name[i] for i in female_counts.index]
)
_ = plt.subplots(figsize=(15, 5))

sns.boxplot(x='wage', data=df)
_, axes = plt.subplots(1, 2, sharey=True, figsize=(6, 6))

sns.boxplot(data=df['wage'], ax=axes[0])
sns.violinplot(data=df['wage'], ax=axes[1])
_ = sns.distplot(df['wage'], bins=10)
sns.jointplot(x='wage', y='exper', data=df, kind='scatter')
sns.jointplot(x='wage', y='exper', data=df, kind="kde", color="r")
df.groupby('looks').wage.sum().plot(
    kind='bar', rot=75, color='#008000'
)
df[['wage', 'exper']].plot(
    kind='density',
    subplots=True,
    layout=(1, 2),
    sharex=False,
    figsize=(10, 4)
)

plt.tight_layout()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20097830710336026, 'fraction_numerical': 0.036154827732879626, 'mean_word_length': 4.714459295261239, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 1, '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': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '551812', 'license': 'MIT', 'n_tokens_mistral': 2276, 'n_tokens_neox': 2093, 'n_words': 314, 'path': 'labs/lab18/demo/pltmpl.ipynb', 'repo_name': 'Alvant/AdvancedPython', 'size': '4702'}