5f892713c3 2021-03-03 1: %%%%%%%%%%%%%%%%%%%%%
5f892713c3 2021-03-03 2: % PLOTTING
5f892713c3 2021-03-03 3: %%%%%%%%%%%%%%%%%%%%%
5f892713c3 2021-03-03 4:
5f892713c3 2021-03-03 5: % Load gnuplot package
5f892713c3 2021-03-03 6: load_package gnuplot$
5f892713c3 2021-03-03 7:
5f892713c3 2021-03-03 8: % Plot of sine and cosine
5f892713c3 2021-03-03 9: plot(sin(x), title="sin(x) and cos(x)", output="Sine and Cosine");
5f892713c3 2021-03-03 10: plot(cos(x), title="sin(x) and cos(x)");
5f892713c3 2021-03-03 11:
5f892713c3 2021-03-03 12: % Superposition of polynomials
5f892713c3 2021-03-03 13: plot((x^2+y^2-9)*x*y=0, title="Polynomials", output="Polynomials");
5f892713c3 2021-03-03 14:
5f892713c3 2021-03-03 15: % 3D surface plot
5f892713c3 2021-03-03 16: plot(cos sqrt(x**2+y**2),x=(-10 .. 10),y=(-10 .. 10),hidden3d, title="cos sqrt(x^2+y^2)", points=50, output="3D Plot");
5f892713c3 2021-03-03 17:
5f892713c3 2021-03-03 18: % Super-Ellipsoid
5f892713c3 2021-03-03 19: on rounded;
5f892713c3 2021-03-03 20: ax:=3$
5f892713c3 2021-03-03 21: ay:=3$
5f892713c3 2021-03-03 22: az:=4$
5f892713c3 2021-03-03 23: ns:=4/5$
5f892713c3 2021-03-03 24: ew:=1$
5f892713c3 2021-03-03 25:
5f892713c3 2021-03-03 26: for all w,m let c(w,m) = sign(cos(w))*abs(cos(w))**m$
5f892713c3 2021-03-03 27: for all w,m let s(w,m) = sign(sin(w))*abs(sin(w))**m$
5f892713c3 2021-03-03 28: for all u,v let x(u,v) =ax * c(v, ns)*c(u, ew)$
5f892713c3 2021-03-03 29: for all u,v let y(u,v) =ay * c(v, ns)*s(u, ew)$
5f892713c3 2021-03-03 30: for all u,v let z(u,v) =az * s(v, ns)$
5f892713c3 2021-03-03 31:
5f892713c3 2021-03-03 32: dd:=pi/15$
5f892713c3 2021-03-03 33: w:=for u:=-pi step dd until pi collect
5f892713c3 2021-03-03 34: for v:=-pi/2 step dd until pi/2 collect
5f892713c3 2021-03-03 35: {x(u,v),y(u,v),z(u,v)}$
5f892713c3 2021-03-03 36: gnuplot(set, ticslevel, 0)$
5f892713c3 2021-03-03 37: gnuplot(set, xtics, -4, 1, 4)$
5f892713c3 2021-03-03 38: gnuplot(set, ytics, -4, 1, 4)$
5f892713c3 2021-03-03 39: gnuplot(set, ztics, -4, 1, 4)$
5f892713c3 2021-03-03 40: plot (w, hidden3d, title="Super-Ellipsoid", output="Super-Ellipsoid")$
5f892713c3 2021-03-03 41:
5f892713c3 2021-03-03 42: % 3D surface plot with gradients using the
5f892713c3 2021-03-03 43: % CAS mode gnuplot operator of the gnuplot
5f892713c3 2021-03-03 44: % package. The same plot could be created
5f892713c3 2021-03-03 45: % using direct gnuplot commands in Plot
5f892713c3 2021-03-03 46: % mode.
5f892713c3 2021-03-03 47: plotreset$
5f892713c3 2021-03-03 48: gnuplot("unset hidden3d");
5f892713c3 2021-03-03 49: gnuplot("unset hidden");
5f892713c3 2021-03-03 50: gnuplot("unset surface");
5f892713c3 2021-03-03 51: gnuplot("set output ""3D Log""");
5f892713c3 2021-03-03 52: gnuplot("set title ""3D Log""");
5f892713c3 2021-03-03 53: gnuplot("set samples 30; set isosamples 30");
5f892713c3 2021-03-03 54: gnuplot("set pm3d");
5f892713c3 2021-03-03 55: gnuplot("set style line 100 lt 5 lw 0.5");
5f892713c3 2021-03-03 56: gnuplot("set pm3d hidden3d 100");
5f892713c3 2021-03-03 57: gnuplot("set view 57,220");
5f892713c3 2021-03-03 58: gnuplot("set xrange [-2:2]");
5f892713c3 2021-03-03 59: gnuplot("set yrange [-2:2]");
5f892713c3 2021-03-03 60: gnuplot("splot log(x*x*y*y)");
5f892713c3 2021-03-03 61: plotshow;
5f892713c3 2021-03-03 62:
5f892713c3 2021-03-03 63: % 3D Torus
5f892713c3 2021-03-03 64: % Again, the same plot could be generated
5f892713c3 2021-03-03 65: % with direct gnuplot commands in Plot
5f892713c3 2021-03-03 66: % mode.
5f892713c3 2021-03-03 67: plotreset$
5f892713c3 2021-03-03 68: gnuplot("set title ""Interlocking Torus""");
5f892713c3 2021-03-03 69: gnuplot("set output ""Torus""");
5f892713c3 2021-03-03 70: gnuplot("set parametric");
5f892713c3 2021-03-03 71: gnuplot("set urange [-pi:pi]");
5f892713c3 2021-03-03 72: gnuplot("set vrange [-pi:pi]");
5f892713c3 2021-03-03 73: gnuplot("set isosamples 50,20");
5f892713c3 2021-03-03 74: gnuplot("unset key");
5f892713c3 2021-03-03 75: gnuplot("unset xtics");
5f892713c3 2021-03-03 76: gnuplot("unset ytics");
5f892713c3 2021-03-03 77: gnuplot("unset ztics");
5f892713c3 2021-03-03 78: gnuplot("set border 0");
5f892713c3 2021-03-03 79: gnuplot("set view 60, 30, 1.5, 0.9");
5f892713c3 2021-03-03 80: gnuplot("set origin 0.0,-0.075");
5f892713c3 2021-03-03 81: gnuplot("set size 0.9, 1.1");
5f892713c3 2021-03-03 82: gnuplot("set colorbox vertical user origin 0.9, 0.15 size 0.02, 0.50");
5f892713c3 2021-03-03 83: gnuplot("set format cb ""%.1f""");
5f892713c3 2021-03-03 84: gnuplot("set pm3d depthorder");
5f892713c3 2021-03-03 85: gnuplot("splot cos(u)+.5*cos(u)*cos(v),sin(u)+.5*sin(u)*cos(v),.5*sin(v) with pm3d, 1+cos(u)+.5*cos(u)*cos(v),.5*sin(v),sin(u)+.5*sin(u)*cos(v) with pm3d");
5f892713c3 2021-03-03 86: plotshow;