-
-
Notifications
You must be signed in to change notification settings - Fork 26
[lp_intro] change the visualization code #475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Many thanks @longye-tian . I like your code and figure a lot better. Can you please increase alpha in the shading of the feasible set, so that the color is more transparent? Then it will be a different color to the blue line. Also, can you please change the iso-revenue lines to black, maybe half the default width, or with alpha=0.6, so they are not too dominant. Finally, can you please change the star at the optimal solution to a dot? Simple is best. |
Dear John @jstac , Sure thing. Just revised the code accordingly. The new code
fig, ax = plt.subplots()
# Draw constraint lines
ax.set_xlim(0,15)
ax.set_ylim(0,10)
x1 = np.linspace(0, 15)
ax.plot(x1, 6-0.4*x1, label="$2x_1 + 5x_2=30$")
ax.plot(x1, 10-2*x1, label="$4x_1 + 2x_2=20$")
# Draw the feasible region
feasible_set = Polygon(np.array([[0, 0],[0, 6],[2.5, 5],[5, 0]]), alpha=0.1)
ax.add_patch(feasible_set)
# Draw the objective function
ax.plot(x1, 3.875-0.75*x1, label="iso-revenue lines",color='k',linewidth=0.75)
ax.plot(x1, 5.375-0.75*x1, color='k',linewidth=0.75)
ax.plot(x1, 6.875-0.75*x1, color='k',linewidth=0.75)
# Draw the optimal solution
ax.plot(2.5, 5, ".", label="optimal solution")
ax.set_xlabel("$x_1$")
ax.set_ylabel("$x_2$")
ax.legend()
plt.show() This indeed looks much better! If you like this output, I will create a pull request using the above code. Best ❤️ |
That's great @longye-tian , please go ahead! |
thanks @longye-tian and @jstac this has now been merged so closing. |
Dear John @jstac ,
This issue tracker is related to #469 about change the visualization code.
The current visualization code is
After our meeting today, I propose to remove the grid, set
x1 = np.linspace(0,15)
and usex1
in the plot code, add legend instead of text and add x,y labels, remove unnecessary color specifications (I add the orange color to the iso-revenue lines so that they are in the same color).My code is shown below:
The current and proposed outputs are shown below:


What do you think about the proposed changes in the visualization code? Would you like to make any changes?
Best ❤️
Longye
The text was updated successfully, but these errors were encountered: