Plotting with method draw_grid

Plotting with method draw_grid#

Se crea un nuevo metodo para plottear un grid de graficas

import time
import numpy as np
import matplotlib.pyplot as plt
import proximitygraphs as pg
uniform_sphere = pg.SetPoints.uniform_sphere(n=1000, seed=0)
H1 = pg.Gamma_Graph(uniform_sphere, gamma0=1, gamma1=-1, closed=True, block_size=128)
H2 = pg.Gamma_Graph(uniform_sphere, gamma0=-1, gamma1=1, closed=True, block_size=128)

pg.draw_grid([H1, H2], 1, 2, figsize=(12, 6), details=True)
(<Figure size 1200x600 with 2 Axes>,
 array([<Axes: title={'center': 'gamma-Neighborhood Graph\ngamma0=1, gamma1=-1, closed=True'}>,
        <Axes: title={'center': 'gamma-Neighborhood Graph\ngamma0=-1, gamma1=1, closed=True'}>],
       dtype=object))
../_images/6ee09453f84a586b115a096b18299889526dc01e8af16f27c922ddd41b8b3b00.png
H1.draw()
(<Figure size 600x600 with 1 Axes>,
 <Axes: title={'center': 'gamma-Neighborhood Graph'}>)
../_images/914eecb58ea8b1f0e30bdeec153a1f17d359cf5a1545d079770654782155d2b8.png
H3 = pg.Gamma_Graph(uniform_sphere, gamma0=-0.5, gamma1=0.5, closed=True, block_size=128),
H4 = pg.Gamma_Graph(uniform_sphere, gamma0=-0.2, gamma1=0.5, closed=True, block_size=128),
H5 = pg.Gamma_Graph(uniform_sphere, gamma0=0.2, gamma1=0.5, closed=True, block_size=128),
H6 = pg.Gamma_Graph(uniform_sphere, gamma0=0.5, gamma1=0.5, closed=True, block_size=128),

graphs = [H3, H4, H5, H6]

pg.draw_grid(graphs, 2, 2, figsize=(10, 10), details=True)
(<Figure size 1000x1000 with 4 Axes>,
 array([[<Axes: title={'center': 'gamma-Neighborhood Graph\ngamma0=-0.5, gamma1=0.5, closed=True'}>,
         <Axes: title={'center': 'gamma-Neighborhood Graph\ngamma0=-0.2, gamma1=0.5, closed=True'}>],
        [<Axes: title={'center': 'gamma-Neighborhood Graph\ngamma0=0.2, gamma1=0.5, closed=True'}>,
         <Axes: title={'center': 'gamma-Neighborhood Graph\ngamma0=0.5, gamma1=0.5, closed=True'}>]],
       dtype=object))
../_images/ac3ed273a8bc5d0ea63c12104fecc30367ac513d4123fdbf99ef6c2faf345bed.png

No method#

fig, axs = plt.subplots(1, 2, figsize=(12, 12), constrained_layout=True)
gammas = [(1, -1), (1, -1)]

for ax, (gamma0, gamma1) in zip(axs, gammas):
    
    H = pg.Gamma_Graph(uniform_sphere, gamma0=gamma0, gamma1=gamma1, closed=True, block_size=128)
    H.draw(ax=ax, details=True)

plt.show()
../_images/d5eeffc67325ccaf083540164e5034e45a2cd21aa4b76190e2d746deebf777ce.png
fig, axs = plt.subplots(2, 2, figsize=(12, 12), constrained_layout=True)
axs_flat = np.ravel(axs)  # length 4, each element is a single Axes

gammas = [(0.5, 0.5), (-0.5, 0.5), (0.5, -0.5), (-0.5, -0.5)]

for ax, (gamma0, gamma1) in zip(axs_flat, gammas):
    t0 = time.perf_counter()
    H = pg.Gamma_Graph(uniform_sphere, gamma0=gamma0, gamma1=gamma1, closed=True, block_size=128)
    H.draw(ax=ax, details=True)  
    t1 = time.perf_counter()
    print(f"gamma0={gamma0}, gamma1={gamma1}\t{t1 - t0:.4f}s")

plt.show()
gamma0=0.5, gamma1=0.5	0.0873s
gamma0=-0.5, gamma1=0.5	0.1033s
gamma0=0.5, gamma1=-0.5	13.0758s
gamma0=-0.5, gamma1=-0.5	11.3831s
../_images/5f403b210caaac1c9d079dc1361b90cbe5f244cd6429670093f73c8f12dc9de5.png
gammas = [
    [(0.1, 0.1), (-0.1, 0.1)],
    [(0.1, -0.1), (-0.1, -0.1)],
]

fig, axs = plt.subplots(2, 2, figsize=(12, 12), constrained_layout=True)

for i in range(2):
    for j in range(2):
        gamma0, gamma1 = gammas[i][j]
        H = pg.Gamma_Graph(uniform_sphere, gamma0=gamma0, gamma1=gamma1, closed=True, block_size=128)
        H.draw(ax=axs[i, j], details=True)

plt.show()
../_images/672603372ec9566bbc5a3594b5f07290c5ac1fad8cd2122b12c04607c131b718.png