-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Expand file tree
/
Copy pathbreak_even_analysis_chart_code.py
More file actions
72 lines (57 loc) · 1.48 KB
/
break_even_analysis_chart_code.py
File metadata and controls
72 lines (57 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# flake8: noqa
import marimo
__generated_with = "0.11.0"
app = marimo.App(width="medium")
@app.cell
def _():
import matplotlib.pyplot as plt
import marimo as mo
return mo, plt
@app.cell
def _():
fixed_cost = 50000
unit_cost = 2
selling_price = 10
upper_production_quantity = 10000
return fixed_cost, selling_price, unit_cost, upper_production_quantity
@app.cell
def _(
fixed_cost,
plt,
selling_price,
unit_cost,
upper_production_quantity,
):
break_even_quantity = fixed_cost / (selling_price - unit_cost)
break_even_income = fixed_cost + break_even_quantity * unit_cost
units = range(0, upper_production_quantity + 1, 1000)
unit_costs = [(x * unit_cost) + fixed_cost for x in units]
sales_income = [unit * selling_price for unit in units]
plt.plot(units, unit_costs, marker="o")
plt.plot(units, sales_income, marker="x")
plt.xlabel("Units Produced")
plt.ylabel("($)")
plt.legend(["Total Costs", "Total Income"])
plt.title("Break-Even Analysis")
plt.vlines(
break_even_quantity,
ymin=0,
ymax=break_even_income,
linestyles="dashed",
)
plt.text(
x=break_even_quantity + 100,
y=int(break_even_income / 2),
s=int(break_even_quantity),
)
plt.grid()
plt.show()
return (
break_even_income,
break_even_quantity,
sales_income,
unit_costs,
units,
)
if __name__ == "__main__":
app.run()