我怎样才能让 x 轴上的最后一个数字(在本例中为 40^7)也显示在图上?
这是我的代码:
\documentclass[11pt]{book}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{float}
\usepackage{pgfplots,pgfplotstable, booktabs}
\pgfplotsset{compat=1.8}
\begin{filecontents*}{nano.csv}
100 -79.374
101.801 -79.858
103.634 -78.587
105.501 -79.077
107.401 -78.735
109.335 -81.799
111.304 -82.298
34884753.53 -150.333
38828202.58 -152.993
39527488.85 -154.021
40000000 -153.788
\end{filecontents*}
\pgfplotsset{minor grid style={dashed,red}}
\pgfplotsset{major grid style={dotted,green!50!black}}
\begin{document}
\begin{figure}[H]
\begin{center}
\begin{tikzpicture}
\begin{semilogxaxis}[xmin = 100, xmax = 40e6, scale = .75, width=20cm,height=10cm, title = {\emph{(a) $P_{T}$ over different samples}},
x tick label style={
/pgf/number format/fixed,
/tikz/.cd
}, xlabel={\emph{Offset Frequency (Hz)}},ylabel={\emph{Phase Noise (dBc/Hz)}}]
\addplot [blue]table[x index=0,y index=1,col sep=space] {nano.csv};
\end{semilogxaxis}
\end{tikzpicture}
\caption[Plot showing (a) position ${\mathbf{P_{T}}}$.]{Plot showing position ${\mathbf{P_{T}}}$.}\label{noise}
\end{center}
\end{figure}
\end{document}
答案1
你的意思是:
为此,我添加了axis
选项extra x ticks = {4e7}
。
附录:根据您的评论:您需要放大xmax
到4'e7
5E7 或更好。
笔记:x
表中的最大值是 或40e6
, 因此将其放大 10 倍4e7
是没有意义的(即: )。xmax
40e7
\documentclass[11pt]{book}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{float}
\usepackage{pgfplots,pgfplotstable, booktabs}
\pgfplotsset{compat=1.8}
\begin{filecontents*}{nano.csv}
100 -79.374
101.801 -79.858
103.634 -78.587
105.501 -79.077
107.401 -78.735
109.335 -81.799
111.304 -82.298
34884753.53 -150.333
38828202.58 -152.993
39527488.85 -154.021
40000000 -153.788
\end{filecontents*}
\pgfplotsset{minor grid style={dashed,red}}
\pgfplotsset{major grid style={dotted,green!50!black}}
\begin{document}
\begin{figure}[htb]
\centering
\begin{tikzpicture}
\begin{semilogxaxis}[
width = 15cm, height=7.5cm,
xmin = 100, xmax = 50e6,
title = {\emph{(a) $P_{T}$ over different samples}},
x tick label style={/pgf/number format/fixed,
/tikz/.cd},
xlabel={\emph{Offset Frequency (Hz)}},
ylabel={\emph{Phase Noise (dBc/Hz)}},
extra x ticks = {40e6}
]
\addplot [blue]table[x index=0,y index=1,col sep=space] {nano.csv};
\end{semilogxaxis}
\end{tikzpicture}
\caption{Plot showing position ${\mathbf{P_{T}}}$.}
\label{noise}
\end{figure}
\end{document}