-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdmb_figures.py
More file actions
38 lines (30 loc) · 1.26 KB
/
dmb_figures.py
File metadata and controls
38 lines (30 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import matplotlib.pyplot as plt
from matplotlib.colors import to_hex
import numpy as np
def generar_colores(N):
valores = np.linspace(0, 1, N)
colores = plt.cm.rainbow(valores)
colores_hex = [to_hex(color) for color in colores]
return colores_hex
class Figura:
def __init__(self, ancho=6.4, ratio=1.33, dpi=200):
# Las siguientes líneas son para homogeneizar las figuras con el estilo de MNRAS
# Se puede comentar si no funcionan correctamente los paquetes de LaTeX
plt.rcParams['text.usetex'] = True
plt.rcParams['text.latex.preamble'] = r'\usepackage[varg]{txfonts}'
plt.rcParams['text.antialiased'] = True
plt.rcParams['xtick.labelsize'] = 13
plt.rcParams['ytick.labelsize'] = 13
plt.rcParams['image.cmap'] = 'rainbow'
fig = plt.figure(figsize=(ancho, ancho / ratio), dpi=dpi)
self.fig = fig
self.dpi = dpi
self.ax = []
def axs(self, ncols=1, nrows=1):
k = 0
for i in range(nrows):
for j in range(ncols):
self.ax.append(self.fig.add_subplot(nrows, ncols, k + 1))
self.ax[-1].tick_params(axis='both')
k = k + 1
return self.fig, self.ax