the-last-thing/code/plots/laplace-adj-graph.py

33 lines
894 B
Python
Raw Permalink Normal View History

2021-08-04 00:02:28 +02:00
#!/usr/bin/env python3
import numpy as np
from matplotlib import pyplot as plt
from scipy.stats import laplace
plt.rc('font', family='serif')
plt.rc('font', size=10)
plt.rc('text', usetex=True)
x = np.arange(0.0, 6.0, 0.01)
# Draw the first laplace distribution.
plt.plot(x,\
laplace.pdf(x, loc=2.0, scale=1.0),\
label=r'$\textrm{Laplace}(2, 1)$',\
color='#009874')
# # Draw the second laplace distribution.
# plt.plot(x,\
# laplace.pdf(x, loc=1.0, scale=1.0),\
# label=r'$\textrm{Laplace}(1, 1)$',\
# color='#e52e4e')
# Configure the plot.
plt.axis([0.0, 6.0, 0.0, 0.6]) # Set plot box.
plt.legend(loc='best', frameon=False) # Set plot legend.
plt.grid(axis='y', alpha=1.0) # Add grid on y axis.
plt.xlabel('Count') # Set x axis label.
plt.ylabel('Probability') # Set y axis label.
plt.show() # Show the plot in a new window.