pgfplots 中有关嵌套轴的错误

pgfplots 中有关嵌套轴的错误
\documentclass[10pt]{book}
\usepackage[paperheight=9in,paperwidth=6in,includehead,includefoot,top=0.5in,bottom=0.5in,outer=0.5in,inner=0.75in]{geometry}

\usepackage{amsfonts}    
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepackage{siunitx}
\usepackage{nicefrac}
\usepackage{tikz}
\usepgfplotslibrary{groupplots}
\usetikzlibrary{arrows}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage[numbers]{natbib}
\numberwithin{equation}{section}
\usepackage{txfonts}
\usepackage{hyphenat}
\usepackage[overload]{textcase} % Otherwise $p_t$ gets capitalized
                                % into $P_T$ in chapter headings,
                                % which is not desirable
\usepackage[colorlinks=true,pdfstartview=FitV,linkcolor=black,citecolor=black,urlcolor=black,plainpages=false,pdfpagelabels]{hyperref}
\usepackage[fit]{truncate}
\usepackage[toctitles]{titlesec}
\usepackage{makeidx}
\makeindex
\usepackage{url}
\usepackage{tocbibind}

\begin{document}
\begin{tikzpicture}
\begin{groupplot}[]

\nextgroupplot[declare function ={fy(\x)=sin(\x+rand*100)^2;}]
\begin{axis} [
xmin=-720, xmax=720,
width=10cm, height=10cm,
tick style=black,
clip mode=individual,
x axis line style={opacity=0},
y axis line style={opacity=0},
ticks=none
]
\end{axis}

\addplot [
ultra thick,
smooth,
tension=1,
samples=30,
domain=-720:720
] {fy(x)};

\draw[latex-latex, xshift=-0.5cm] ({rel axis cs:0,0}|-{rel axis cs:0,0}) -- ({rel    axis cs:0,0}|-{rel axis cs:0,1}) node[left, pos=0.5] {$h$};


\end{tikzpicture}
\end{document}

这是一个生成随机频率图的代码,为什么我会收到以下错误

! Package pgfplots Error: Sorry, nested axis environments are not supported. Pl
ease move the inner axis environment below \end{axis} and use alignment options
 (for example named nodes, see manual) to place it at the desired position.

See the pgfplots package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.43 ]

?

如何解决此错误?

任何帮助都将受到赞赏。

答案1

我只是删除了所有杂乱的部分,只留下了相关的部分。之后,删除不必要的部分就可以编译代码了。

  1. 我不明白这一点\begin{groupplot}[],它没有用\end{}条款结束

  2. 我将其放在declare functiontikz 环境上

所以:

\documentclass[10pt]{article}
\usepackage{tikz}

\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[declare function ={fy(\x)=sin(\x+rand*100)^2;}]
\begin{axis} [
xmin=-720, xmax=720,
width=10cm, height=10cm,
tick style=black,
clip mode=individual,
x axis line style={opacity=0},
y axis line style={opacity=0},
ticks=none
]

\addplot [
ultra thick,
smooth,
tension=1,
samples=30,
domain=-720:720
] {fy(x)};

\draw[latex-latex, xshift=-0.5cm] ({rel axis cs:0,0}|-{rel axis cs:0,0}) -- ({rel    axis cs:0,0}|-{rel axis cs:0,1}) node[left, pos=0.5] {$h$};
\end{axis}


\end{tikzpicture}

\end{document}

解决方案

相关内容