Closed longye-tian closed 3 days ago
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.
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
alpha=0.1
for the feasible set linewidth=0.75
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$")
feasible_set = Polygon(np.array([[0, 0],[0, 6],[2.5, 5],[5, 0]]), alpha=0.1) ax.add_patch(feasible_set)
ax.plot(x1, 3.875-0.75x1, label="iso-revenue lines",color='k',linewidth=0.75) ax.plot(x1, 5.375-0.75x1, color='k',linewidth=0.75) ax.plot(x1, 6.875-0.75*x1, color='k',linewidth=0.75)
ax.plot(2.5, 5, ".", label="optimal solution") ax.set_xlabel("$x_1$") ax.set_ylabel("$x_2$") ax.legend()
plt.show()
The output is shown below:
<img width="580" alt="revised plot" src="https://github.com/QuantEcon/lecture-python-intro/assets/133612246/b963ed24-4c07-4262-8777-e74a486f6971">
This indeed looks much better!
If you like this output, I will create a pull request using the above code.
Best ❤️
Longye
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