In [1]:
%matplotlib inline

In [2]:
import matplotlib.pyplot as plt
import numpy as np

x = np.arange(0,10,0.1)

# The lines to plot
y1 = 4 - 2*x
y2 = 3 - 0.5*x
y3 = 1 -x

# The upper edge of polygon (min of lines y1 & y2)
y4 = np.minimum(y1, y2)

# Set y-limit, making neg y-values not show in plot
plt.ylim(0, 5)

# Plotting of lines
plt.plot(x, y1,
         x, y2,
         x, y3)

# Filling between line y3 and line y4
plt.fill_between(x, y3, y4, color='grey', alpha='0.5')
plt.show()



In [3]:
import numpy as np
import matplotlib.pyplot as plt
 
x = np.linspace(0, 2, 80)
 
plt.figure()
plt.fill_between(x, x**2, 4, facecolor = 'SteelBlue')
plt.show()
plt.close()



In [4]:
import numpy as np
import matplotlib.pyplot as plt
 
xn = np.linspace(-4, 4, 100)
yn = 1/(np.sqrt(2*np.pi))*np.exp(-0.5*xn**2)
points = np.logical_or((xn < -1.645), (xn > 1.645))
 
plt.figure()
plt.plot(xn, yn, 'Black')
plt.plot(xn, np.zeros(xn.size), 'Black')
plt.fill_between(xn, 0, yn, facecolor='Purple', where=points)
plt.xlim(-4, 4)
plt.ylim(-0.05, 0.45)
plt.title('Normal Distribution')
plt.text(-3.5, 0.35, 'Rejection zone')


Out[4]:
<matplotlib.text.Text at 0x78e0ba8>

In [5]:
import numpy as np
import matplotlib.pyplot as plt
 
x1 = np.linspace(-2, 2, 80)
x2 = np.linspace(0, 2, 80)
 
plt.figure(figsize = (6, 3))
plt.subplot(121)
plt.fill(x1, x1**2, 'SteelBlue')
plt.title('Symetric Quadratic')
 
plt.subplot(122)
plt.fill(x2, x2**2, 'SteelBlue')
plt.title('Quadratic on the\n Positive Quadrant')
plt.show()



In [6]:
import matplotlib.pyplot as plt

# define corner points
x = [1,2,1,0]
y = [2,1,0,1]

# plot
plt.fill(x,y)
plt.show()



In [ ]:


In [ ]: