Python matplotlib Supply and Demand with Excise Tax

import matplotlib.pyplot as plt
import numpy as np

# Define the supply and demand functions
def supply(P, t):
    return 360 * (P - t) - 720

def demand(P):
    return 960 - 120 * P

# Define the price range
P = np.linspace(0, 6, 100)

# Define the tax amount
t = 2

# Plot the supply and demand curves
plt.plot(P, supply(P, 0), label="Original Supply")
plt.plot(P, supply(P, t), label="New Supply")
plt.plot(P, demand(P), label="Demand")

# Plot the equilibrium points
plt.scatter(3.5, 540, label="Original Equilibrium")
plt.scatter(4.25, 450, label="New Equilibrium")

# Plot the tax wedge
plt.fill_between(P, supply(P, t), supply(P, 0), color="gray", alpha=0.5, label="Tax Wedge")

# Add labels and title
plt.xlabel("Price ($ per bottle)")
plt.title("Supply and Demand with Excise Tax")

What is the problem? Please don’t simply dump code.

That’s fine, just if it is, it must be in Showcase if it is just that.

1 Like