## 2D Graphics (More)

2次元グラフィックについてのもう少し進んだ話題． まず最初は，ベクトル場の表示．
In[79]:=
`Needs["Graphics`PlotField`"]`
In[80]:=
`PlotVectorField[ {Sin[x],Cos[y]}, {x,0,Pi}, {y,0,Pi} ]`
Out[80]=
`-Graphics-`

In[81]:=
`Needs["Graphics`MultipleListPlot`"]`
In[82]:=
```MultipleListPlot[
Table[{x, Sin[2 Pi x]}, {x,0,1,0.1}],
Table[{x, Cos[2 Pi x]}, {x,0,1,0.1}],
PlotJoined->True ]```
Out[82]=
`-Graphics-`
ここからデータ処理の例として，回帰関数の推定を行う．
In[83]:=
`Needs["Graphics`Graphics`"]`
まず，最初の50個の素数をデータとする(Table, Prime)．
In[84]:=
`primes = Table[ Prime[n], {n,1,50} ]`
Out[84]=
```{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43,

47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101,

103, 107, 109, 113, 127, 131, 137, 139, 149, 151,

157, 163, 167, 173, 179, 181, 191, 193, 197, 199,

211, 223, 227, 229}```
データをプロットする(ListPlot)．
In[85]:=
`graph1 = ListPlot[primes, PlotStyle->PointSize[0.01] ]`
Out[85]=
`-Graphics-`

In[86]:=
`p[x_] = Fit[ primes, {1,x,x^2}, x ]`
Out[86]=
```                                  2
-6.22531 + 3.24613 x + 0.0300397 x```

In[87]:=
`graph2 = Plot[ p[x], {x,1,50} ]`
Out[87]=
`-Graphics-`
データと回帰関数のグラフを重ねて表示する(Show)．
In[88]:=
`Show[ graph1, graph2 ]`
Out[88]=
`-Graphics-`
2乗誤差を求める(Sum)．
In[89]:=
`Sum[ (primes[[n]]-p[n])^2, {n,1,50} ]`
Out[89]=
`322.743`

In[90]:=
```DisplayTogether[
ListPlot[Table[Prime[n],{n,1,100}],
PlotStyle->PointSize[0.01] ],
Plot[ p[x], {x,1,100} ]
]```
Out[90]=
`-Graphics-`
パイチャートを表示する．
In[91]:=
`PieChart[ {0.1,0.2,0.3,0.4}, PieExploded->{{1,0.2}} ]`
Out[91]=
`-Graphics-`

In[92]:=
```neko = Transpose[
{{8, 4}, {6, 4}, {4, 6}, {5, 10}, {6, 8}, {8, 8},
{9, 10}, {10, 6}, {8, 4}, {8, 0}, {7, 2}, {2, 2},
{1, 0}, {1, 4}, {0, 3}, {0, 5}, {5, 5}} ]```
Out[92]=
```{{8, 6, 4, 5, 6, 8, 9, 10, 8, 8, 7, 2, 1, 1, 0, 0, 5},

{4, 4, 6, 10, 8, 8, 10, 6, 4, 0, 2, 2, 0, 4, 3, 5,

5}}```

In[93]:=
```egaku[n_] := Show[
Graphics[{Thickness[0.02],Line[Transpose[n]]}],
AspectRatio->Automatic, Axes->True ]```
In[94]:=
`egaku[neko]`
Out[94]=
`-Graphics-`

In[95]:=
`rot[a_] := {{Cos[a],-Sin[a]},{Sin[a],Cos[a]}}`
In[96]:=
`egaku[rot[Pi/4] . neko]`
Out[96]=
`-Graphics-`

In[97]:=
`Needs["Miscellaneous`WorldPlot`"]`
In[98]:=
`WorldPlot[{World,RandomGrays}]`
Out[98]=
`-WorldGraphics-`

Dept. CS / Faculty of Eng. / Kobe Univ. / Naoyuki Tamura