Multilple plots on the same gragh

I’m able to graph two functions with plots

using Plots

U(E,W)= (40-E)^2/sqrt(W) #Utility function
E = 0:40
W = 10:100

B(E,W)= -(40-E)/W # budget line function
E = 0:40

How would I get these on the same plot, so that I can manipulate them?

In general, you would use ! to add to any plot, such as:


For example, using contour (and borrowing code from the documentation),

x = y = range(-20, 20, length = 100)
contour(x, y, (x, y) -> x^2 + y^2)
contour!(x, y, (x, y) -> x + y)

gets you this plot:

It seems that in your example, your scales are too different for both plots to be seen in the same figure (the range of z in the first is [0, 500], the range of z in the second is [-4, 0]).

OK, I thought I had the formula wrong. BL is supposed to be lines that pivot from E=40, at W=0 to E=0, W=E*W