在下面的代码中,图例中有一个标记。我只有两个没有任何标记的图。如何删除这些标记并只让线条显示在图例条目中?
这是我的代码:
\documentclass{book}
\usepackage{tikz}
\usepackage{pgfplots}
\clearpage
\pgfplotsset{minor grid style={dotted,gray!50}}
\pgfplotsset{major grid style={gray!50!black}}
\begin{filecontents*}{Noise.dat}
Freq Orig Filt
100.000, -79.374, -119.392
101.801, -79.858, -119.321
103.634, -78.587, -117.497
1000, -79.077, -117.437
1070.401, -78.735, -116.547
1090.335, -81.799, -119.065
11100.304, -82.298, -119.021
11300.309, -82.329, -118.511
115000.349, -81.744, -117.389
\end{filecontents*}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[every plot/.append style={very thick}]
\begin{semilogxaxis}[width=14cm,height=10cm,
grid = both,
every major grid/.style={gray, opacity=0.7},
title = {},
xlabel={\emph{Offset Frequency (Hz)}},
ylabel={\emph{Phase Noise (dBc/Hz)}}]
\addplot table[mark = none, x index=0,y index=1,col sep=comma] {Noise.dat};
\addlegendentry{\emph{Original Phase Noise Data}}
\addplot table[mark = none, x index=0,y index=2,col sep=comma] {Noise.dat};
\addlegendentry{\emph{Filtered Noise Data}}
\end{semilogxaxis}
\end{tikzpicture}
\caption[Original and Filtered Response.]{Original and Filtered Response.}
\end{figure}
\end{document}
答案1
问题在于,您添加了mark=none
选项table
,而不是 选项\addplot
。您应该写\addplot+ [mark=none] table ...
。+
表示 不会完全覆盖 线条的样式[mark=none]
,因此颜色循环将继续。如果没有 ,+
您将得到一条黑线。
要制作所有图,very thick
您可以添加every axis plot/.append style={very thick}
到axis
选项中,通过添加no markers
选项,axis
所有图中将没有标记。
顺便说一句,您可以在一个 中添加多个内容\pgfplotsset
,只需用逗号分隔即可。您的\clearpage
序言中也有一个游离部分,整个情节比 更宽\textwidth
,导致它突出到右边距。
\documentclass{book}
\usepackage{pgfplots}
\pgfplotsset{
minor grid style={dotted,gray!50},
major grid style={gray!50!black}
}
\begin{filecontents*}{Noise.dat}
Freq Orig Filt
100.000, -79.374, -119.392
101.801, -79.858, -119.321
103.634, -78.587, -117.497
1000, -79.077, -117.437
1070.401, -78.735, -116.547
1090.335, -81.799, -119.065
11100.304, -82.298, -119.021
11300.309, -82.329, -118.511
115000.349, -81.744, -117.389
\end{filecontents*}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{semilogxaxis}[width=\textwidth,height=10cm,
grid = both,
every major grid/.style={gray, opacity=0.7},
title = {},
xlabel={\emph{Offset Frequency (Hz)}},
ylabel={\emph{Phase Noise (dBc/Hz)}},
no markers,
every axis plot/.append style={very thick}]
\addplot table[x index=0,y index=1,col sep=comma] {Noise.dat};
\addlegendentry{\emph{Original Phase Noise Data}}
\addplot table[x index=0,y index=2,col sep=comma] {Noise.dat};
\addlegendentry{\emph{Filtered Noise Data}}
\end{semilogxaxis}
\end{tikzpicture}
\caption[Original and Filtered Response.]{Original and Filtered Response.}
\end{figure}
\end{document}