タイトル通り,MathematicaでつくったグラフをTikZでお化粧してTeXに取り込む方法のメモです.
まず素材となるグラフをMathematicaでちゃっとつくります.
Plot[PDF[LogNormalDistribution[0, 1], x], {x, 0, 5}, PlotStyle -> {Black}, Frame -> True, FrameTicks -> {{{0, 0.2, 0.4, 0.6}, None}, {{0, 1, 2, 3, 4, 5}, None}}]
このグラフにlogn_pdf
という名前をつけて保存しておきます.
次にTeXのFigure環境の中にTiKZでグリッドを描きます.\includegraphics
で先ほどつくったlogn_pdf
を
読み込むのですが,tikzpicture
環境の中で読み込むのがポイントです.
\begin{figure}[H] \centering \begin{tikzpicture} \draw[step=1,black!0] (0,0) grid (12,5); \node[anchor=south west] (image) at (1.5,-0.5) {\includegraphics[width=0.7\linewidth]{logn_pdf}}; \node [right] at (4.432,3.5) {$\displaystyle \frac{1}{\sqrt{2 \pi \sigma^2} x}\exp \left\lbrace -\frac{(\log x-\mu)^2}{2\sigma^2}\right\rbrace$}; \node [right] at (0.7,4.8){$f(x)$}; \node [right] at (10,0){$x$}; \end{tikzpicture} {\small 対数正規分布の確率密度関数$f(x)$のグラフ. $\mu=0,\sigma=1$} \end{figure}
できあがりー.
グラフの中と周りにTeX
の数式がきちんと挿入されました.
R Mrakdown
やJupyter notebook
でも同様のことができます.
ぜひお試しを.