From 8891d3368dd1cdf2183047e431670bf9076ec383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gi=C3=B9=20Marcer?= Date: Fri, 5 Jun 2020 23:48:32 +0200 Subject: [PATCH] ex-1: move from pdfs-plot.py things about 1-notes.pdf and both.pdf to this new program. --- ex-1/slides-plot.py | 61 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 ex-1/slides-plot.py diff --git a/ex-1/slides-plot.py b/ex-1/slides-plot.py new file mode 100755 index 0000000..d8955be --- /dev/null +++ b/ex-1/slides-plot.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python + +from matplotlib import pyplot as plt +import numpy as np +import sys + + +def moyal(x, μ, σ): + N = (1)/(np.sqrt(2 * np.pi) * σ) + return N * np.exp(- 0.5 * ((x - μ)/σ + np.exp( - (x - μ)/σ))) + + +# plt.figure() +plt.figure(figsize=(3.5, 2.5)) +plt.rcParams['font.size'] = 8 + +# useful coordinates +# y_min = -0.0086 # y min axes +# y_max = 0.1895 # y max axes +# me = -0.22 # mode +# f_me = 0.1806 # f(mode) +# h_f_me = f_me/2 # falf f(mode) +# x_m = -1.5867 # x₋ +# x_p = 2.4330 # x₊ + +# prepare plot +x, y = np.loadtxt(sys.stdin, unpack=True) +# plt.title('Landau distribution', loc='right') +# plt.xlim(-10, 10) +# plt.ylim(y_min, y_max) + +# draw the lines +# plt.plot([-10, me], [f_me, f_me], color='gray') +# plt.plot([me, me], [f_me, y_min], color='gray') +# plt.plot([-10, x_p], [h_f_me, h_f_me], color='gray') +# plt.plot([x_m, x_m], [y_min, h_f_me], color='gray') +# plt.plot([x_p, x_p], [y_min, h_f_me], color='gray') + +# draw the function +plt.plot(x, y, color='#92182b') + +# draw the notes +# s = 0.012 +# S = 0.2 +# plt.annotate('$f(m_e)$', [-10 + S, f_me - s]) +# plt.annotate('$f(m_e)/2$', [-10 + S, h_f_me - s]) +# plt.annotate('$x_-$', [x_m + S, y_min + s/2]) +# plt.annotate('$x_+$', [x_p + S, y_min + s/2]) +# plt.annotate('$m_e$', [me + S, y_min + s/2]) + +# do Moyal plot +μ = -0.22278298 +σ = 1.1191486 +x = np.arange(-10,30, 0.01) +plt.plot(x, moyal(x, μ, σ), color='gray') + +# save figure +plt.tight_layout() +plt.show() +# plt.savefig('notes/images/1-notes.pdf') +# plt.savefig('slides/images/both-pdf.pdf', transparent=True)