我按照以下方式绘制此图对话虽然我无法理解该declare function
部分,因此采用了相同的值以更接近我需要的值。但是,我需要进行以下修改:
- 将 x 轴标签从轴的下方移动到右方,并删除刻度和值 -3、-2 等。
- 改变图表的纵横比:将高度降低到当前高度的 0.75 倍左右,将宽度增加到当前宽度的 1.5 倍。
这是我的代码:
\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{nccmath, amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\usepgfplotslibrary{groupplots,fillbetween}
\DeclareMathOperator{\CDF}{cdf}
\DeclareMathOperator{\PDF}{pdf}
\begin{document}
\begin{tikzpicture}[declare function={%
normcdf(\x,\m,\s)=1/(1 + exp(-0.07056*((\x-\m)/\s)^3 - 1.5976*(\x-\m)/\s));
gauss(\x,\u,\v)=1/(\v*sqrt(2*pi))*exp(-((\x-\u)^2)/(2*\v^2));
}]
\begin{groupplot}
[group style={group size=1 by 2},
xmin=-3,xmax=3,ymin=0,
domain=-3:3, xlabel=Time, axis lines=left]
\nextgroupplot[ylabel=Marginal Response, ytick=\empty, ymax=1]
\addplot[smooth, black,thick, xtick=\empty] {gauss(x,0,1)};
\draw [dashed](0,0)--(0,1);
\draw [dashed](3,0)--(3,1);
\nextgroupplot[ylabel=Cumulative Response, ytick=\empty, ymax=1]
\addplot[smooth, black,thick] {normcdf(x,0,1)};
\draw [dashed](0,0)--(0,2);
\draw [dashed](3,0)--(3,2);
\end{groupplot}
\end{tikzpicture}
\end{document}
答案1
width
您可以使用和键设置宽度和高度height
。您之前已经使用ytick=\empty
来删除 y 刻度,另一个xtick=\empty
将删除 x 刻度。您可以通过以下方式移动 x 标签
xlabel style={at={(axis description cs:1,0)},anchor=north east},
为了获得穿过组图的线,您可以定义在环境中使用的符号坐标tikzpicture
。
\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{nccmath, amsmath}
%\usepackage{graphicx}% loaded by tikz
%\usepackage{tikz}% loaded by pgfplots
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\usepgfplotslibrary{groupplots,fillbetween}
\DeclareMathOperator{\CDF}{cdf}
\DeclareMathOperator{\PDF}{pdf}
\begin{document}
\begin{tikzpicture}[declare function={%
normcdf(\x,\m,\s)=1/(1 + exp(-0.07056*((\x-\m)/\s)^3 - 1.5976*(\x-\m)/\s));
gauss(\x,\u,\v)=1/(\v*sqrt(2*pi))*exp(-((\x-\u)^2)/(2*\v^2));
}]
\begin{groupplot}
[group style={group size=1 by 2},
xmin=-3,xmax=3,ymin=0,width=12cm,height=6cm,
xtick=\empty,ytick=\empty,ymax=1,
xlabel style={at={(axis description cs:1,0)},anchor=north east},
domain=-3:3, xlabel=Time, axis lines=left]
\nextgroupplot[ylabel=Marginal Response]
\addplot[smooth, black,thick, xtick=\empty] {gauss(x,0,1)};
\path (0,\pgfkeysvalueof{/pgfplots/ymax}) coordinate (t1)
(3,\pgfkeysvalueof{/pgfplots/ymax}) coordinate (t2);
\nextgroupplot[ylabel=Cumulative Response]
\addplot[smooth, black,thick] {normcdf(x,0,1)};
\path (0,\pgfkeysvalueof{/pgfplots/ymin}) coordinate (b1)
(3,\pgfkeysvalueof{/pgfplots/ymin}) coordinate (b2);
\end{groupplot}
\draw[dashed] (b1) -- (t1);
\draw[dashed] (b2) -- (t2);
\end{tikzpicture}
\end{document}