Saturday, December 21, 2019

Mesh Functions


Manipulate[ComplexPlot[z^3-z^2+1/z,{z,-1.4-1.4 I,1.4+1.4 I},
PlotPoints->50,Mesh->Automatic, MeshStyle->{Gray,White},
ImageSize->500,MeshFunctions->meshfunction],
{meshfunction,
{{Log10[Abs[#2]]&,Arg[#2]&},{Abs[Re[#2]]^.5&,Abs[Im[#2]]^.5&},
{Cos[#2]^.01&,Sin[#2]^.01&},
{Cos[Log10[Abs[#2]]]&,Sin[Log10[Abs[#2]]]&}}}]


ComplexPlot & DensityPlot Examples


Manipulate[ComplexPlot[z^4+1/z^4,
{z,-1.4-1.4 I,1.4+1.4 I},ColorFunction->colfun,ImageSize->500],
{colfun,{"CyclicLogAbs","CyclicLogAbsArg",
"ShiftedCyclicLogAbs","CyclicReImLogAbs"}}]


DensityPlot[Arg[(x+I y)^4+1/(x+I y)^4],
{x,-1.4,1.4},{y,-1.4,1.4},PlotPoints->200,
ColorFunction->(Hue[#/(2 Pi)] &),
ColorFunctionScaling->False,ImageSize->500]


Arrow Plotting


MF=CharacterRange["\[LeftArrow]","⇿"];
CF2=Function[{p},ColorData["DarkRainbow"][p]];
With[{g={2Sin[2x],Sin[x]-Cos[2x]}},
Show[ Graphics[Table[{CF2[t/(2Pi)],
Arrowheads[{{.001,1}}],Arrow[{g,Normalize[D[g,x]]+g}],
Text[Style[MF[[Floor[14t+1]]],Large],Normalize[D[g,x]]+g]}/.x->t,
{t,0,2Pi,.07}]],ImageSize->700]]


Vectors & Functions


Manipulate[With[{f={Sin[k1*t],Cos[k2*t]+Cos[k3*t]}},
Show[Table[Graphics[{Hue[t/100],
Arrow[{{Sin[t],Cos[t]},
f+{Sin[t],Cos[t]}}]}],
{t,0,100Pi}],ImageSize->{500,500}]],
{k1,Range[1,5,1]},{k2,Range[5,9,1]},{k3,Range[4,8,1]}]


Interactive Graph Styling


Manipulate[CompleteGraph[12,
EdgeStyle->Flatten[Table[Table[k<->j->Hue[k/12],
{k,12}],{j,2,V}]],
VertexStyle->Flatten[Table[k->Hue[k/12],{k,12}]]],
{V,Range[12,2,-1]}]


Colorized Graphs


ERF[weights_]:={
ColorData["BrightBands"][Rescale[weights[[Sequence@@#2]],
{Min@weights,Max@weights}]],
Thickness[0.01],Opacity[0.75],Arrow[#1]}&;
GP[weights_]:=GraphPlot[
WeightedAdjacencyGraph[weights],
Method -> "StarEmbedding",VertexStyle->LightGray,
VertexSize->.15,VertexShapeFunction->"ConcaveHexagon",
EdgeRenderingFunction->(ERF[weights]),ImageSize->500]
GP[SparseArray[{i_,j_}:>i+j,{9,9}]]


Exploration of Color Palettes


RF=Function[{p},Rescale[p/16,{.5,1}]];
CF=Function[{p},ColorData["BrightBands"][p]];
CPG[n_]:=GraphPlot[PetersenGraph[n,7],
VertexStyle->CF[1-RF[n]],VertexShapeFunction->"ConcaveHexagon",
VertexSize->.3,EdgeStyle->CF[RF[n]],
EdgeShapeFunction->"CarvedArrow"];
Table[CPG[N],{N,{9,10,11,12}}]


Plot Themes


DG=GraphData["DesarguesGraph","Graph","All"];
PT={ "Classic","Business","Detailed",
"Scientific","Minimal","Web","Marketing"};
Multicolumn[Table[GraphPlot[DG[[i]],
PlotTheme->PT[[i]],PlotLabel->PT[[i]]],{i,7}],4]


Graphics 3D & Functions


With[{f ={Sin[3t],Cos[7 t]+Cos[4t],Cos[t]}},
          Graphics3D[Table[Arrow[Tube[{{Sin[t],Cos[t],0},
          f +{Sin[t],Cos[t],1}}]],{t,0,100Pi}],
          Boxed->False,ImageSize->700]]


ParametricPlot3D Examples


X1=(2+Cos[v/2]*Sin[u]-Sin[v/2]*Sin[5u])*Cos[v];
X2=6u Cos[v];
Y1=(2+Cos[v/3]*Sin[u]-Sin[v/2]*Sin[4u])*Sin[v];
Y2=6u Sin[v];
Z1=16Abs[Sin[v/2]*Sin[u]+Cos[v/2]*Sin[4u]];
Z2=4Im[(u Exp[I v]^5)^(1/5)];
tpp1=Table[ParametricPlot3D[{i*X1,i*Y1,Z1},
{u,0,2Pi},{v,0,2Pi},Mesh->None,
ColorFunction->"RoseColors",
PlotStyle->Opacity[0.5]],{i,3}];
tpp2=ParametricPlot3D[{X2,Y2,Z2},
{u,0,2},{v,0,2 Pi}, Mesh->None,
ExclusionsStyle->{None,Gray},
PlotStyle->Directive[Darker[Green],Opacity[0.7]]];   
Show[tpp1,tpp2,Axes->False,
Boxed->False,PlotPoints->20,ImageSize->700]


MatrixPlot Examples


rl={{.5,"a"},{1.5,"b"},{2.5 ,"c"},{3.5,"d"},{4.5,"e"},{5.5, "f"},{6.5,"g"},{7.5,"h"}};
cl={{.5,"\[WhiteKing]"},{1.5,"\[WhiteQueen]"},

{2.5 ,"\[WhiteRook]"},{3.5,"\[WhiteBishop]"},
{4.5,"\[WhiteKnight]"},{5.5,"\[WhitePawn]"},
{6.5,"\[BlackKing]"},{7.5,"\[BlackQueen]"},

{8.5,"\[BlackRook]"},{9.5,"\[BlackBishop]"},
{10.5,"\[BlackKnight]"},{11.5,"\[BlackPawn]"}};
Show[MatrixPlot[m,ColorFunction->(Darker[Hue[2#]]&)],
        Table[Graphics[{White,Text[m[[j]][[i]],{i-.45,8.45-j}]}],{i,12},{j,8}],
     FrameTicks->{cl,rl},FrameTicksStyle->Medium,ImageSize->700]


Grid Examples


m=RandomReal[{0,1},{8,12}];
Grid[MapThread[Prepend,

{Prepend[m,CharacterRange["\[WhiteKing]","\[BlackPawn]"]],
Prepend[CharacterRange["a","h"],""]}],
Frame->All,FrameStyle->Dashed,
Background->{{Table[ColorData["Pastel"][i/12],{i,12}]}}]


PolarPlot Drawing


cfbb=Function[{x,y,t,r},ColorData["BrightBands"][r]];
cfdb=Function[{x,y,t,r},ColorData["DarkBands"][r]];
pp1=PolarPlot[Exp[Cos[t]^2+Sin[t]]-3Cos[4t]+Sin[t/12],
{t, 0,6\[Pi]},ColorFunction->cfbb];
pp2=PolarPlot[-Floor[t]*Sin[t]/2,{t,0,6Pi},
ExclusionsStyle->Dashed,ColorFunction->cfdb];
Show[pp1,pp2,Axes->False,PlotStyle->Thick,ImageSize->500]


PolarPlot & ParametricPlot


tpp=PolarPlot[Evaluate[Table[Cos[12t]+i,{i,3}]],{t,0,2Pi},
ColorFunction->Function[{x,y,t,r},ColorData["CandyColors"][r]],
RegionFunction->Function[{x,y,t,r},Cos[12t]<0.75]];
trp=ParametricPlot[Evaluate[Table[{(Cos[12t]/2+i)*Cos[t],
(Cos[12t/2]+i)*Sin[t]},{i,3}]],{t,0,2Pi},
ColorFunction->Function[{x,y,t},
ColorData["CandyColors"][Abs[Cos[12t]]]]];
Show[tpp,trp,Axes->False,ImageSize->500]



ListLinePlot & BSplineCurve


ListLinePlot[Table[{Sin[2t],Cos[7 t]+Cos[t]},
{t,0,2 Pi,Pi/75}],Axes -> False,ImageSize->500]/.
Line[rest_]:>{Arrowheads[Table[.05,{i, 0, 1,.03}]],
Arrow[BSplineCurve@rest]}



Symbol Plotting


Print[CharacterRange["æ•°","æ–€"]];CharacterRange["⚐","⚜"]
Print[FromCharacterCode[Range[8592,8647,1]]];
FromCharacterCode[Range[8648,8703,1]]
tf=Table[{n*Cos[n/4],n*Sin[n/4]},{n,8703-8591}];
mf=ToString /@ CharacterRange["\[LeftArrow]","⇿"];
ListPlot[List /@tf,PlotMarkers->mf,
PlotStyle->"DarkBands",ImageSize->700]


Interactive Point Plotting


Manipulate[Graphics[Table[{Hue[(i+10*j)/100],PointSize[0.0001*i],
Point[{Cos[Pi*i/50]^3+j,j*Sin[Pi*i/50]/3}]},{i,100},{j,N}],
GridLines->Automatic,ImageSize->Large,Axes->True],{N,Range[1,5,1]}]


ReImPlot Examples


ReImPlot[{ArcSin[(2-5*I)^x], ArcCos[(2-5*I)^x]},
{x,-5,5},ColorFunction->Hue,PlotStyle->Thickness[0.01],
ImageSize->700,PlotLabels -> "Expressions",
GridLines->Automatic]


ParametricPlot for Complex Numbers


z1=1+5*I; z2=4-3*I;
ParametricPlot[{ReIm[(z1)^x/5],ReIm[(z2)^x/5],
ReIm[(z1+z2)^x/5],ReIm[(z1-z2)^x],
ReIm[(z1*z2)^(x/10)],ReIm[(z1/z2)^(10x)]},
{x,-10,10},PlotStyle->"BrightBands",PlotTheme->"Detailed",
PlotRange->{{-10,10},{-10,10}},PlotLegends->"Expressions"]


Complex Numbers as PlayGrounds


z1=1+4*I; z2=2-3*I;
Z={z1,z2,z1+z2,z1-z2,z1*z2,z1/z2,z1^2,N[z2^(1/3)]}
tc=Table[Graphics[{Hue[i/8],Thickness[0.005],
Opacity[0.8],Arrowheads[0.04],
Arrow[{{0,0},ReIm[Z[[i]]]}]}],{i,8}];
tx=Table[Graphics[{Text[Style[Z[[i]],
Hue[i/8],FontSize->Medium],
ReIm[Z[[i]]],{-1,-1}]}],{i,8}];
Show[tc,tx,ImageSize->Large]


Sigmoid Activation


synapse0=RandomVariate[NormalDistribution[0,1],3]
sigmoid[x_]=1.0/(1+Exp[-x]); sigmoidderivation[x_]=x*(1.0-x);
sigmoid/@X==sigmoid[X]
Do[{layer0=X;layer1=sigmoid[Dot[layer0,synapse0]];
layer1error=layer1-Y;
layer1delta=layer1error*sigmoidderivation[layer1];
synapse0derivative=Dot[Transpose[layer0],layer1delta];
synapse0=synapse0-synapse0derivative},{i,100}]
TableForm[{X,layer1,Y}]