Skip to content

Instantly share code, notes, and snippets.

@hbshrestha
Last active September 22, 2021 15:14
Show Gist options
  • Save hbshrestha/f804d5b64a53febfb6d03d0d5afc68ca to your computer and use it in GitHub Desktop.
Save hbshrestha/f804d5b64a53febfb6d03d0d5afc68ca to your computer and use it in GitHub Desktop.
plt.figure(figsize = (10,8))
plt.rcParams["font.size"] = 15
plt.axis([0, 50, 0, 50])
#Hours constraint of machine A
x = np.array([0,50]); y = 33 - 1.5*x
plt.plot(x, y, "red", label = "Machine A Hours Constraint")
plt.fill_between([0, 22], [33,0], color = "red", alpha = 0.05)
#Hours constraint of machine B
x = np.array([0, 50]); y = 45 - 2.25*x
plt.plot(x, y, "blue", label = "Machine B Hours Constraint")
plt.fill_between([0, 20], [45,0], color = "blue", alpha = 0.05)
#Hours Constraint of Machine C
x = np.array([0, 50]); y = 20 - 0.2*x
plt.plot(x, y, "green", label = "Machine C Hours Constraint")
plt.fill_between([0, 100], [20,0], color = "green", alpha = 0.05)
#Indicate optimal product strategy
plt.plot(10,18, marker = "o", color = "red", markersize= 10)
plt.annotate("Optimal Product Strategy", xy = (10,18), xytext = (20,30),
arrowprops = dict(shrink =.1, width = 1,headwidth = 5))
plt.plot(16,9, marker = "o", color = "pink", markersize= 10)
plt.plot(20, 0, marker = "o", color = "b",markersize = 10)
plt.annotate("X only", xy = (20,0.5), xytext= (25,10), arrowprops = dict(width = 1, headwidth = 5))
plt.plot(0,33,marker = "o", color = "blue", markersize = 10)
plt.annotate("Y only", xy = (0,33), xytext = (5,40), arrowprops = dict(width = 1,headwidth = 5))
#Indicate feasibility space
plt.text(3, 6, "Feasibility\n Space", fontdict = {"weight":"bold"})
plt.annotate("", xy = (3,6), xytext = (0,0), arrowprops = dict( width = 0.5, headwidth = 5))
plt.xlabel("Number of units of X produced"); plt.ylabel("Number of units of Y produced")
plt.title("Optimization of production")
plt.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment