2021年3月14日星期日

How to label intersection of lines using matplotlib?

I'm very new to coding and in one of my classes, we're supposed to solve basic linear optimization problems graphically. I know you can do this by coding, but I wasn't sure how, so for the class I've just been drawing the plots using graph paper. It's been pretty tiresome. But today I figured out how to graph the lines, so now my question is if there is a way to label the (x,y) coordinates of where the lines intersect each other? Or perhaps if there is a way to plot minor tick grid lines? As it stands, the basic plot I created below makes it hard to tell what the intersecting points are.

I would also appreciate a way to shade in the area beneath all three lines. This is considered the "feasible region" for an optimization problem.

I posted a basic plot I had to create for a previous assignment

import matplotlib.pyplot as plt  plt.plot([24,0],[0,4])  plt.plot([16,0],[0,8])  plt.plot([10,0],[0,10])  plt.grid()  # This command shows the grid.  plt.show()  

Thanks in advance!

https://stackoverflow.com/questions/66631501/how-to-label-intersection-of-lines-using-matplotlib March 15, 2021 at 10:05AM

没有评论:

发表评论