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