This Mathematica notebook shows examples of how I make (most) graphs for the Intermediate Microeconomics class. 
If you have never used Mathematica, read at least these first: 
https://www.wolfram.com/language/fast-introduction-for-math-students/en/entering-input 
https://www.wolfram.com/language/fast-introduction-for-math-students/en/notebook-documents

Aalto students can install Mathematica by following the instructions here
https://download.aalto.fi 
A free version is also available for everyone with a Raspberry Pi  https://en.wikipedia.org/wiki/Raspberry_Pi

Marko Terviö 2022-09-23

Example: Making graphs for PS 2.3

Recall problem 2.3 (Northland Transport). 
Let’s turn the assumptions of that problem into definitions.

fc=7200;
mc=20; (* semicolon suppresses output, but is not required *)
TC[q_]:=fc+mc q
Pd[q_]:=200-q

Take a derivative of revenue to get marginal revenue

MR[q_]=D[Pd[q]q,q]

Profit-maximization must satisfy MR=MC

Solve[MR[q]==mc,q]
qM=q/.%[[1]]
pM=Pd[qM]

Solve gives a list of solutions, even when there is just one. Solutions are “rules” like q->90. Notice that double equality == defines an equation that may be solved, whereas a single equality = would assign a value for the symbol on the left hand side (as I did earlier with mc=20)

% refers to previous output
[[1]] refers to first element of a list
q/.(rule) extracts the value of q as defined by the (rule)

Calculate maximized profits and resulting CS

pM qM -TC[qM]
(Pd[0]-pM)qM/2

More generally, CS is defined as

Integrate[Pd[q]-pM,{q,0,qM}]

Let' s graph Marginal Cost, Demand, and Marginal Revenue

Plot[{mc,Pd[q],MR[q]},{q,0,200}]

Let' s add some options to get a better graph

figureBasic=Plot[{mc,Pd[q],MR[q]},{q,0,200},
PlotStyle->{Blue,Red,{Red,Dashed}},
PlotLegends->{"MC","(P^d)","MR"},
AxesLabel->{"Q","P"},
PlotRange->{All,{0,All}}]

Plot command has many options. Mathematica’s official documentation is very good and often has great examples, see here
https://reference.wolfram.com/language/ref/Plot.html

or access the documentation from a command line by preceding the command with ?

?Plot

Let' s define some regions to highlight in the graph

csArea=Polygon[{{0,Pd[0]},{0,Pd[qM]},{qM,Pd[qM]}}];
psArea=Rectangle[{0,Pd[qM]},{qM,mc}];

and also add some lines and text:

figAreas=Graphics[{
{Opacity[.3],Red,csArea,Blue,psArea},
{Gray,Dashed,Line[{{qM,0},{qM,Pd[qM]},{0,Pd[qM]}}]},
{Black,Text["CS",{0.5qM,0.2Pd[0]+0.8Pd[qM]}],Text["Profits+FC",{0.5qM,0.5(Pd[qM]+mc)}]}}
]

Inside the Graphics command curly brackets { } delineate the scope for attributes like color and opacity.

Show command superimposes multiple graphs. It inherits options from the first graph.

figMonopolyPricing=Show[figureBasic,figAreas]

Finally we can export the graph

Export["/home/tervio/Dropbox/Micro/handouts/MS_monopoly_regulation_2022_a.pdf",figMonopolyPricing]

SystemOpen[%]

The exact look of the graph also depends on the settings in the local Mathematica environment (e.g., font options for Plot). If you haven’t changed them then you get whatever happen to be the default options on your computer (which is usually fine). This is a more advanced topic, here is more about it:

?SetOptions

Part b) Average cost pricing

AC[q_]=TC[q]/q

Solve[AC[q]==Pd[q],q]
qAC=Max[q/.%]
pAC=Pd[%]

figACpricing=Show[figureBasic,
Plot[AC[q],{q,0,200},
PlotStyle->{{Blue,Dashed}},
PlotLegends->{"AC"},
PlotRange->{All,{0,1.05Pd[0]}}]
]

By now you know how to add garnish to this graph.

Much more about getting started with Mathematica

If you are fluent  in some programming language like Python then this is the best introduction to Mathematica (aka Wolfram programming language):
https://www.wolfram.com/language/fast-introduction-for-programmers/en

Here is the standard gigantic introduction: 
https://www.wolfram.com/language/elementary-introduction/