Matplotlib Plot Example

#!/usr/bin/python3 # ================================================================== # plot bell curve # ================================================================== import numpy as np import matplotlib.pyplot as plt # ------------------------------------------------------------------ # ---- return a list of Y values that fit a bell curve # ---- (normal distribution) associated with a list of X values # ---- # ---- equation to create a list of Y values from a list of X values # ---- x = np.arange(-100,100,10) # ---- y = ymax * pow(np.e,-pow((x-mean),2.0)/(2.0*sd*sd)) # ------------------------------------------------------------------ # ---- return a Y value that fit a bell curve # ---- (normal distribution) associated with a X value # ---- # ---- equation to create a Y value from a X value # ---- x = 100.0 # ---- y = ymax * pow(np.e,-pow(x-mean,2.0)/(2.0*sd*sd)) # ---- # ---- note: what happens when the parentheses around (x-mean) # ---- are remove. # ------------------------------------------------------------------ def BellCurveValue(x,ymax,mean,sd): y = ymax * pow(np.e,-pow((x-mean),2.0)/(2.0*sd*sd)) return y # ------------------------------------------------------------------ # ---- main # ------------------------------------------------------------------ x = np.arange(-300,300,10) # list of X values mean = 0 # population mean value sd = 60 # population standard deviation size = 10 # size of dots in plot window ymax = 100 # population maximum Y value y = BellCurveValue(x,ymax,mean,sd) # returns a list of Y values # ---- remove mathplotlib toolbar plt.rcParams['toolbar'] = 'None' # ---- line plot ##plt.figure(figsize=(8,4), layout='tight') plt.figure(layout='tight') plt.plot(x, y, color='black', linewidth=1) plt.title('Bell Curve Demo Plot') plt.xlabel('X Axis') plt.ylabel('Y Axis') ## ---- scatter plot ##plt.scatter(x, y,color='red',s=size) plt.show() # Question: what does plt.show(block=None) do?