Untitled
unknown
plain_text
7 days ago
1.3 kB
2
Indexable
Never
# Data for the lemonade stand example quantity_lemonade = np.array([1, 2, 3]) # Quantity sold price_lemonade = np.array([2, 1.5, 1]) # Price for each quantity total_revenue_lemonade = price_lemonade * quantity_lemonade # Total revenue for each quantity # Marginal Revenue Calculation marginal_revenue_lemonade = np.array([total_revenue_lemonade[0], total_revenue_lemonade[1] - total_revenue_lemonade[0], total_revenue_lemonade[2] - total_revenue_lemonade[1]]) # Plotting the graph plt.figure(figsize=(10, 6)) # Demand Curve plt.plot(quantity_lemonade, price_lemonade, label="Demand Curve (Price)", marker='o', color='blue') # Marginal Revenue Curve plt.plot(quantity_lemonade, [2, 1, 0], label="Marginal Revenue (MR)", marker='o', linestyle='--', color='green') # Titles and labels plt.title("Lemonade Stand: Demand and Marginal Revenue", fontsize=16) plt.xlabel("Quantity of Lemonade Sold (Q)", fontsize=12) plt.ylabel("Price / Marginal Revenue", fontsize=12) plt.xticks(range(1, 5)) # Set x ticks for clarity plt.yticks(np.arange(0, 3, 0.5)) # Set y ticks for clarity plt.axhline(0, color='black', linewidth=0.8, linestyle='--') # Adding a legend plt.legend() plt.grid(True) # Show the plot plt.show()
Leave a Comment