Plot the solution of a system of linear inequalities

浪子不回头ぞ 提交于 2019-12-08 13:22:25

问题


I have two arrays of numbers from [-1,1]:

a = 2*np.random.sample(100)-1 and b = 2*np.random.sample(100)-1. These two arrays define the following system of linear inequalities

a[i]*x + b[i]*y <= 1 for i = 0,1,..., 99

The solution-set of this system is a convex polygon. How to draw it using matplotlib? As I understand,fill_between allows to do this only for case of two inequalities.


回答1:


You can use the fillplots package (http://fillplots.readthedocs.org) that does exactly what you are looking for. A few examples are available at http://fillplots.readthedocs.org/en/latest/examples.html.



来源:https://stackoverflow.com/questions/24620827/plot-the-solution-of-a-system-of-linear-inequalities

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!