<jupyter_start><jupyter_text>Различные графики<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Regular plot<jupyter_code>n = 512
X = np.linspace(0, np.pi/2, n, endpoint=True)
Y = np.cos(20*X) * np.exp(-X)

plt.figure(figsize=(8,4), dpi=80)
# Plot upper sine wave
plt.plot(X, Y+2, color='green', alpha=1.00)
plt.fill_between(X, 2, Y+2, color='green', alpha=0.10)

# Plot lower sine wave
plt.plot(X, Y-1, color='orange', alpha=1.00)
plt.fill_between(X, -1, Y-1, (Y-1) > -1, color='#FFAA00', alpha=0.15)
plt.fill_between(X, -1, Y-1, (Y-1) < -1, color='#AAAA00', alpha=0.15)

plt.plot([0, np.pi/2], [0.5, 0.5], 'b--')
# Set x, y limits
plt.xlim(0, np.pi/2)
plt.ylim(-2.5, 3.5)

# Do not plot grids
plt.xticks([])
plt.yticks([])
# plt.grid(False)<jupyter_output><empty_output><jupyter_text>Scatter plot<jupyter_code># Create 2D random signal
n = 512
np.random.seed(1)
X = np.random.randn(n)
Y = np.random.randn(n)
T = np.arctan2(Y, X)

plt.figure(figsize=(6,6), dpi=80)
plt.scatter(X, Y, s=80, c=T, alpha=.60)

plt.xlim(-1.5,1.5), plt.xticks([])
plt.ylim(-1.5,1.5), plt.yticks([])

T.mean()<jupyter_output><empty_output><jupyter_text>Bar plot<jupyter_code>n = 10
# Create two random vectors
X = np.arange(n)
np.random.seed(10)
Y1 = (1-X/float(n)) * np.random.uniform(0.5, 1.2, n)
Y2 = (1-X/float(n)) * np.random.uniform(0.5, 1.2, n)

# Plot two bars
plt.figure(figsize=(8,4), dpi=80)
plt.bar(X, +Y1, facecolor='#CCCCFF', edgecolor='red')
plt.bar(X, -Y2, facecolor='#FFCCCC', edgecolor='blue')

# Plot text into bars
for x,y in zip(X, Y1):
    plt.text(x+0.2, +y+0.07, '%.2f' % y, ha='center', va='bottom')

for x,y in zip(X, Y2):
    plt.text(x+0.2, -y-0.07, '%.2f' % y, ha='center', va='top')

plt.xlim(-1, n) 
plt.ylim(-1.35, +1.35)
plt.grid()<jupyter_output><empty_output><jupyter_text>Contour Plots<jupyter_code># Create function
def f(x, y):
    # return (x+x**4-y**5+y**2) * np.exp(-(0.95*x**2+0.65*y**2))
    return (0.5-x+x**5+y**3-y) * np.exp(-(0.85*x**2+0.75*y**2))

# Create vectors and mesh
n = 200
x = np.linspace(-3, 3, n)
y = np.linspace(-3, 3, n)
X,Y = np.meshgrid(x,y)

# Plot
plt.figure(figsize=(6,6), dpi=80)
plt.contourf(X, Y, f(X,Y), 9, alpha=.75, cmap=plt.cm.hot)

C = plt.contour(X, Y, f(X,Y), 9, colors='black')
plt.clabel(C, inline=1, fontsize=8)
plt.grid(False)<jupyter_output><empty_output><jupyter_text>Imshow<jupyter_code># Create function
def f(x, y):
    return (x+x**4-y**5+y**2) * np.exp(-(0.95*x**2+0.65*y**2))

# Create vectors and mesh
n = 200
x = np.linspace(-3, 3, n)
y = np.linspace(-3, 3, n)
X,Y = np.meshgrid(x,y)
Z = f(X,Y)

# Plot
plt.figure(figsize=(6,6), dpi=80)
plt.imshow(Z, interpolation='bicubic', cmap='bone', origin='lower')
plt.colorbar(shrink=.70)
plt.grid(False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.23341610500177368, 'fraction_numerical': 0.06491663710535651, 'mean_word_length': 4.97457627118644, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '18602', 'license': 'MIT', 'n_tokens_mistral': 1477, 'n_tokens_neox': 1389, 'n_words': 250, 'path': 'matplotlib/plot_some.ipynb', 'repo_name': 'hukenovs/py-tutorial', 'size': '2819'}