<jupyter_start><jupyter_text>Import libraries<jupyter_code>import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from math import sin, pi
import warnings

from qbstyles import mpl_style<jupyter_output><empty_output><jupyter_text>Choose between interactive or static plots:<jupyter_code># interactive plots:
# %matplotlib notebook

# static plots:
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Test plot definitions:<jupyter_code># LINE PLOT
def line_plot(ax):
    rng = np.random.RandomState(4)
    x = np.linspace(0, 10, 500)
    y = np.cumsum(rng.randn(500, 4), 0)
    ax.set_title('Line Graph')
    ax.set_xlabel('— Time')
    ax.set_ylabel('— Random values')
    ax.legend(['Bitcoin', 'Ethereum', 'Dollar', 'Oil'])
    ax.set_xlim([0, 10])
    ax.set_ylim([-20, 60])
    ax.plot(x, y)

# SCATTER PLOT
def scatter_plot(ax):
    rng = np.random.RandomState(4)
    x = np.linspace(0.6, pi-0.6, 100)
    y = [sin(x) + rng.rand() - 0.5 for x in x]
    t = np.linspace(-1, pi+0.2, 300)
    z = [0.5*sin(x*5) + rng.rand() - 0.5 for x in t]
    ax.set_title('Scatter Plot')
    ax.set_xlabel('— space')
    ax.set_ylabel('— altitude')
    ax.legend(['sun', 'mountain'])
    plt.xlim([-0.2, pi+0.2])
    plt.ylim([-1.6, 1.6])
    ax.scatter(x, y, s=100, alpha=.6, color='C2')
    ax.scatter(t, z, s=100, alpha=.6, marker='^', color='C1')

# DISTRIBUTIONS
def distribution_plot(ax):
    np.random.seed(2)
    data = np.random.multivariate_normal((0, 0), [(5, 2), (2, 2)], size=2000)
    data[:, 1] = np.add(data[:, 1], 2)
    ax.set_title('Distribution Plot')
    ax.set_xlabel('— Density')
    ax.set_ylabel('— Random values')
    ax.set_xlim([-10, 10])
    ax.set_ylim([0, 0.31])
    
    # supress seaborn FutureWarnings
    warnings.simplefilter(action='ignore', category=(FutureWarning, UserWarning))
    for col in range(2):
        sns.distplot(data[:, col], ax=ax, color='C' + str(col+3))

# POLAR PLOT
def polar_plot(ax):
    r = np.arange(0, 3.0, 0.01)
    theta = 2 * pi * r
    ax.plot(theta, r)
    ax.plot(0.5 * theta, r, ls='--')
    ax.set_title("Polar Axis Plot")<jupyter_output><empty_output><jupyter_text>Plot all in a subplot<jupyter_code>def plot():
    fig, axes = plt.subplots(2, 2, figsize=(15, 10))
    line_plot(axes[0, 0])
    scatter_plot(axes[0, 1])
    distribution_plot(axes[1, 0])
    ax = plt.subplot(2, 2, 4, projection='polar')
    polar_plot(ax)
    plt.tight_layout()<jupyter_output><empty_output><jupyter_text>Use QB's style:<jupyter_code>mpl_style()
plot()
mpl_style(dark=False)
plot()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1746031746031746, 'fraction_numerical': 0.04103755323267518, 'mean_word_length': 3.988416988416988, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '317446', 'license': 'Apache-2.0', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1065, 'n_words': 216, 'path': 'example.ipynb', 'repo_name': 'berkaybulut/qbstyles', 'size': '2583'}