I’ve just came across a clever trick to draw implicit functions in gnuplot, here. The idea is to use the level curves of the surface plot.
With this trick we can draw indifference curves of CES utility function quite easily. See my scripts on gist.
| # | |
| # GNUPLOT script to draw CES functions with different parameters | |
| # | |
| # script based on the implicit function plotting trick from: | |
| # http://gnuplot-surprising.blogspot.de/2011/09/assume-three-is-equation-fxygxy-and-we.html | |
| # uncomment in case you want to save it to a file | |
| #set term png enhanced lw 2 font "Times,18" | |
| #set output "ces_elas.png" | |
| set contour | |
| set cntrparam levels discrete 1 | |
| set view map | |
| unset surface | |
| set title "Implicit plot of CES functions (different subst. elasticities)" | |
| set xrange [0:10] | |
| set yrange [0:10] | |
| sigma_1 = 2 | |
| rho_1 = 0.5 | |
| f(x,y)=0.25*(0.5*x**rho_1 + 0.5*y**rho_1)**(1/rho_1) | |
| sigma_2 = 4 | |
| rho_2 = 0.75 | |
| g(x,y)=0.25*(0.5*x**rho_2 + 0.5*y**rho_2)**(1/rho_2) | |
| sigma_3 = 1 | |
| rho_3 = 1 # linear function | |
| h(x,y)=0.25*(0.5*x**rho_3 + 0.5*y**rho_3)**(1/rho_3) | |
| sigma_4 = 10 | |
| rho_4 = 0.9 | |
| i(x,y)=0.25*(0.5*x**rho_4 + 0.5*y**rho_4)**(1/rho_4) | |
| splot f(x,y),g(x,y),h(x,y),i(x,y) | |