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
|
# -n → agrs.note → do the Landau plot with the notes
|
||||||
# -b → args.both → do the Landau-Moyal plot
|
# -b → args.both → do the Landau-Moyal plot
|
||||||
|
# -m → args.area → do the Landau median plot
|
||||||
|
|
||||||
|
|
||||||
def moyal(x, μ, σ):
|
def moyal(x, μ, σ):
|
||||||
@ -25,7 +26,7 @@ def main(args):
|
|||||||
|
|
||||||
elif args.save:
|
elif args.save:
|
||||||
plt.rcParams['font.size'] = 8
|
plt.rcParams['font.size'] = 8
|
||||||
if args.both:
|
if (args.both or args.area):
|
||||||
plt.figure(figsize=(3, 2))
|
plt.figure(figsize=(3, 2))
|
||||||
elif args.note:
|
elif args.note:
|
||||||
plt.figure(figsize=(5, 3))
|
plt.figure(figsize=(5, 3))
|
||||||
@ -69,6 +70,13 @@ def main(args):
|
|||||||
x, y = np.loadtxt(sys.stdin, unpack=True)
|
x, y = np.loadtxt(sys.stdin, unpack=True)
|
||||||
plt.plot(x, y, color='#92182b', label='Landau')
|
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
|
# do Moyal plot
|
||||||
if args.both:
|
if args.both:
|
||||||
μ = -0.22278298
|
μ = -0.22278298
|
||||||
@ -86,6 +94,8 @@ def main(args):
|
|||||||
plt.savefig('notes/images/1-notes.pdf')
|
plt.savefig('notes/images/1-notes.pdf')
|
||||||
if args.both:
|
if args.both:
|
||||||
plt.savefig('slides/images/both-pdf.pdf', transparent=True)
|
plt.savefig('slides/images/both-pdf.pdf', transparent=True)
|
||||||
|
if args.area:
|
||||||
|
plt.savefig('slides/images/median.pdf', transparent=True)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -103,5 +113,8 @@ if __name__ == '__main__':
|
|||||||
parser.add_argument('-n', '--note',
|
parser.add_argument('-n', '--note',
|
||||||
action='store_true', default=False,
|
action='store_true', default=False,
|
||||||
help='do the note plot')
|
help='do the note plot')
|
||||||
|
parser.add_argument('-a', '--area',
|
||||||
|
action='store_true', default=False,
|
||||||
|
help='do the area plot')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
main(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