Ok, I don't know if I am just over thinking this, but I have been tearing my hair out trying to think about this. I have looked at plenty of linear programming examples and solutions online and I can't find anything that explains how the optimised function is drawn.
For example, there is a situation where you are trying to minimise the cost of potatoes and soybeans where $x_s$ is the amount of soybeans and $x_p$ is the amount of potatoes.
Soybeans cost twice the amount that potatoes do so we have a cost function of $C = x_p + 2x_s$ which we are trying to minimize.
There are some other constraints involved which I understand how to derive:
- $2x_p + 3x_s \ge 12$
- $4x_p + x_s \ge 8$
- $x_p \ge 0 $ and $x_s \ge 0 $
The following graph is shown in the answer to the question where the blue line represents the cost function and the red star is the optimal solution (which I also know how to find once the cost function is drawn)
What is the logic behind drawing the blue graph line from $C = x_p + 2x_s$? (Sorry if I am just being really stupid but please explain it I need to sleep.)


The blue line is perpendicular to all the lines of the form $x_p+2x_s=c$ where $c$ is a constant, i.e. to the level sets of the cost function. So each point on it has a different cost, and the cost goes down as you move to the left. The slope of the blue line is $2$ because the slopes of the level sets of the cost function are all $-1/2$. So this graphical technique reduces the optimization question to "what is the leftmost point on the blue line such that if you draw the line perpendicular to the blue line through that point, there is a point on that line in the feasible region?"
This is a little bit of a weird way to do it, I think, but it does work.