缩放图像以使数学文本变小

缩放图像以使数学文本变小

由于您无法设置数学符号的大小,我想知道我们是否可以将图像缩放得更大,以便数学看起来更小?

另外,我希望能够将子图的 x 轴和 y 轴更改为与样本图像相似?

最后,这可能很困难,但可以为与平均值和方差大致匹配的分布添加一些浅灰色的样本曲线/路径,并具有一些随机曲率,类似于下面的例子?

旋转正态分布

样本实现

答案1

要增加图的大小,只需调整width高度即可。问题的第二部分我不明白。指示平均值和方差很简单。

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\pgfmathsetmacro{\offset}{0.05}
\begin{tikzpicture}[font=\sffamily,
declare function={gauss(\x,\y,\z)=\offset+1/(\y*sqrt(2*pi))*exp(-((\x-\z)^2)/(2*\y^2));}]

\begin{axis}[samples=101,smooth,hide axis,width=20cm,height=11cm]
\addplot [domain=-3:3] ({gauss(x,0.8,0)},x);
\addplot [domain=-3:3] ({1+gauss(x,1.2,0)},1+x);
\addplot [domain=-3:3] ({2+gauss(x,0.6,0)},x);
\foreach [count=\Y starting from 0] \vari/\DeltaX in {0.8/0,1.2/1,0.6/0} 
{\typeout{\vari/\DeltaX}
\edef\temp{\noexpand\draw[gray] ({\Y+\offset},{\vari+\DeltaX}) -- ({\Y+gauss(\vari,\vari,0)},{\vari+\DeltaX})
({\Y+\offset},{-\vari+\DeltaX}) -- ({\Y+gauss(\vari,\vari,0)},{-\vari+\DeltaX})
 (\Y+\offset,\DeltaX) -- ({\Y+gauss(0,\vari,0)},\DeltaX)
;}
\temp}

\draw[-latex] (0,-3) --  (0,3) coordinate[pos=0.4](x1) coordinate[pos=0.5] (y1)
node[below right,rotate=-90]{$x(t_i)$};
\draw[-latex] (0,-3) -- (0.5,-3) node[below left,rotate=-90]{$f\bigl(x(t_i)\bigr)$};
\draw (1,-2) -- (1,4) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
\draw (2,-3) -- (2,3) coordinate[pos=0.6](x3) coordinate[pos=0.5] (y3);
\addplot[-latex] coordinates{(-0.5,-4) (3,-4)};
\path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3);
\coordinate (t) at (3,-4.1);
\coordinate (xi) at (-0.6,4);
\addplot[-latex] coordinates{(-0.5,-4) (3,-4)};
\addplot[-latex] coordinates{(-0.5,-4) (-0.5,4)};
\end{axis}
\foreach \X in {1,2,3}
{\fill (x\X) circle (2pt);
\draw ([xshift=-1mm]y\X) -- ([xshift=1mm]y\X);
\draw ([yshift=1mm]z\X) -- ([yshift=-1mm]z\X) node[below] {$\X$};}
\node[anchor=north east] at (t) {time};
\node[anchor=north east] at (xi) {$x(t)$};
\draw[blue,thick,shorten >=2mm,shorten <=2mm] (x1) -- (x2);
\draw[blue,thick,shorten >=2mm,shorten <=2mm] (x2) -- (x3);
\end{tikzpicture}
\end{document}

在此处输入图片描述

或者你也可以减小字体的大小。

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\pgfmathsetmacro{\offset}{0.05}
\begin{tikzpicture}[font=\sffamily\small,
declare function={gauss(\x,\y,\z)=\offset+1/(\y*sqrt(2*pi))*exp(-((\x-\z)^2)/(2*\y^2));}]

\begin{axis}[samples=101,smooth,hide axis,width=15cm,height=8cm]
\addplot [domain=-3:3] ({gauss(x,0.8,0)},x);
\addplot [domain=-3:3] ({1+gauss(x,1.2,0)},1+x);
\addplot [domain=-3:3] ({2+gauss(x,0.6,0)},x);
\foreach [count=\Y starting from 0] \vari/\DeltaX in {0.8/0,1.2/1,0.6/0} 
{\edef\temp{\noexpand\draw[gray] ({\Y+\offset},{\vari+\DeltaX}) -- ({\Y+gauss(\vari,\vari,0)},{\vari+\DeltaX})
({\Y+\offset},{-\vari+\DeltaX}) -- ({\Y+gauss(\vari,\vari,0)},{-\vari+\DeltaX})
 (\Y+\offset,\DeltaX) -- ({\Y+gauss(0,\vari,0)},\DeltaX)
;}
\temp}
\begin{scope}[thick]
\draw[-latex] (0,-3) --  (0,3) coordinate[pos=0.4](x1) coordinate[pos=0.5] (y1)
node[below right,rotate=-90]{$x(t_i)$};
\draw[-latex] (0,-3) -- (0.5,-3) node[below left,rotate=-90]{$f\bigl(x(t_i)\bigr)$};
\draw[-latex] (1,-2) -- (1,4) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
\draw[dashed] (0,-3) -- (0,-3.5);
\draw[-latex] (2,-3) -- (2,3) coordinate[pos=0.6](x3) coordinate[pos=0.5] (y3);
\draw[dashed] (1,-2) -- (1,-3.5);
\path (0,-4) coordinate (z1) (1,-4) coordinate (z2) (2,-4) coordinate (z3);
\draw[dashed] (2,-3) -- (2,-3.5);
\coordinate (t) at (3,-4.1);
\coordinate (xi) at (-0.6,4);
\addplot[-latex] coordinates{(-0.5,-3.5) (3,-3.5)};
\addplot[-latex] coordinates{(-0.5,-3.5) (-0.5,3.5)};
\end{scope}
\pgfplotsinvokeforeach{1,...,20}{
\draw[very thin] plot[smooth] coordinates 
{(0,{sign(2*rand-1)*(exp(-rand/0.8)-1)}) 
(1,{1+sign(2*rand-1)*(exp(-rand/1.6)-1)})
(2,{sign(2*rand-1)*(exp(-rand/1.2)-1)})};}
\end{axis}
\foreach \X in {1,2,3}
{\fill (x\X) circle (2pt);
\draw ([xshift=-1mm]y\X) -- ([xshift=1mm]y\X);
\draw ([yshift=1mm]z\X) -- ([yshift=-1mm]z\X) node[below] {$\X$};}
\node[anchor=north east] at (t) {time};
\node[anchor=north east] at (xi) {$x(t)$};
\draw[blue,thick,shorten >=2mm,shorten <=2mm] (x1) -- (x2);
\draw[blue,thick,shorten >=2mm,shorten <=2mm] (x2) -- (x3);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容