diff --git a/ex-1/plots/slides.py b/ex-1/plots/misc.py similarity index 82% rename from ex-1/plots/slides.py rename to ex-1/plots/misc.py index 95342ba..85710dd 100755 --- a/ex-1/plots/slides.py +++ b/ex-1/plots/misc.py @@ -11,11 +11,12 @@ import sys # # -n → agrs.note → do the Landau plot with the notes # -b → args.both → do the Landau-Moyal plot +# -m → args.area → do the Landau median plot def moyal(x, μ, σ): N = (1)/(np.sqrt(2 * np.pi) * σ) - return N * np.exp(- 0.5 * ((x - μ)/σ + np.exp( - (x - μ)/σ))) + return N * np.exp(- 0.5 * ((x - μ)/σ + np.exp(- (x - μ)/σ))) def main(args): @@ -25,7 +26,7 @@ def main(args): elif args.save: plt.rcParams['font.size'] = 8 - if args.both: + if (args.both or args.area): plt.figure(figsize=(3, 2)) elif args.note: plt.figure(figsize=(5, 3)) @@ -69,6 +70,13 @@ def main(args): x, y = np.loadtxt(sys.stdin, unpack=True) plt.plot(x, y, color='#92182b', label='Landau') + # Color the area under the function + if args.area: + median = 1.3557804 + x0 = np.argmin(abs(median - x)) + plt.fill_between(x[:x0], y[:x0], color='#ff99a8') + plt.fill_between(x[x0:], y[x0:], color='#b28e94') + # do Moyal plot if args.both: μ = -0.22278298 @@ -86,6 +94,8 @@ def main(args): plt.savefig('notes/images/1-notes.pdf') if args.both: plt.savefig('slides/images/both-pdf.pdf', transparent=True) + if args.area: + plt.savefig('slides/images/median.pdf', transparent=True) if __name__ == '__main__': @@ -103,5 +113,8 @@ if __name__ == '__main__': parser.add_argument('-n', '--note', action='store_true', default=False, help='do the note plot') + parser.add_argument('-a', '--area', + action='store_true', default=False, + help='do the area plot') args = parser.parse_args() main(args) diff --git a/slides/images/median.pdf b/slides/images/median.pdf new file mode 100644 index 0000000..30bd305 Binary files /dev/null and b/slides/images/median.pdf differ