import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
# Settings
mpl.rcParams['savefig.bbox'] = 'tight'
mpl.rcParams['figure.figsize'] = 6.4,4.8
mpl.rcParams['axes.titlesize'] = 10
mpl.rcParams['axes.labelsize'] = 10
mpl.rcParams['xtick.labelsize'] = 10
mpl.rcParams['ytick.labelsize'] = 10
mpl.rcParams['legend.fontsize'] = 10
# Parameters
x = np.linspace(0,4,513)
p = np.array([0,0.2,0.5,0.8,1,1.25,2,5,np.inf])
def getcolor(p):
l = p**2/(1+p**2) if p < np.inf else 1.
c = mpl.colormaps["Spectral"](l)
c = mpl.colors.rgb_to_hsv(c[0:3])
c[1] = 1 #Oversaturate
c[2] *= 0.95
c = mpl.colors.hsv_to_rgb(c[0:3])
print(p, mpl.colors.to_hex(c), mpl.colors.rgb_to_hsv(c))
return c
# Normal
fig,ax = plt.subplots()
for k in range(len(p)):
if p[k] == 0:
label = "$\\beta \\rightarrow 0$"
elif p[k] == np.inf:
label = "$\\beta \\rightarrow \\infty$"
else:
label = "$\\beta = %g$"%p[k]
ax.plot(x, np.exp(-x**p[k]), color=getcolor(p[k]), label=label, ls='-' if 0<p[k]<np.inf else (2,(1,1)))
ax.set_xlim(min(x),max(x))
ax.set_ylabel("")
ax.set_ylim(0,None)
ax.minorticks_on()
ax.grid(True,c=(0.9,0.9,0.9),ls='-',which='major')
ax.legend(frameon=True, fancybox=False, framealpha=1, facecolor='white')
fig.savefig('Stretched exponential.svg')