Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. %matplotlib inline
  4.  
  5. arr=np.array([[-1,1,2,-1,2],
  6. [9,-1,-6,5,6]])
  7. arr=np.vstack([arr,[2,-1,2,1,0]])
  8. arr[0]+=arr[1]
  9. arr[2]-=arr[1]
  10. arr[1]=arr[1]*5-arr[0]
  11.  
  12. # Строим графики
  13.  
  14. plt.plot(x, y1, label=r'$y\geqslant2$')
  15. plt.plot(x, y2, label=r'$2y\leq25-x$')
  16. plt.plot(x, y3, label=r'$4y\geq 2x - 8$')
  17. plt.plot(x, y4, label=r'$y\leq 2x-5$')
  18. plt.xlim((0, 16))
  19. plt.ylim((0, 11))
  20. plt.xlabel(r'$x$')
  21. plt.ylabel(r'$y$')
  22.  
  23. # Закрашиваем область допустимых планов
  24.  
  25. y5 = np.minimum(y2, y4)
  26. y6 = np.maximum(y1, y3)
  27.  
  28. plt.fill_between(x, y5, y6, where=y5>y6, color='grey', alpha=0.5)
  29. plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement