ex-1: change name from slides.py to misc.py
Also add the possibility to create the median.pdf plot.
This commit is contained in:
parent
336e8aa734
commit
bbc1945609
@ -11,6 +11,7 @@ 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, μ, σ):
|
||||
@ -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)
|
BIN
slides/images/median.pdf
Normal file
BIN
slides/images/median.pdf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user