我刚刚开始使用 pgfplot。我正在尝试准备一个如下图所示的图
\begin{figure}[h]
\centering
\begin{tikzpicture}
\begin{axis}[minor tick num=1, axis x line=middle, axis y
line=middle, xlabel=$k$, ylabel=$\omega$, ymin=0,xmin=-2,ymax=60]
\addplot[blue,domain=0:5, line width=1.5pt] {x^2+25};
\addplot[orange,domain=0:5,line width=1pt]{3*x+22.75};
\addplot[cyan,domain=0:1.5, line width=1pt,dashed]{18.166*x};
\node[coordinate,pin=right:{$v_{\phi}=\frac{\omega}{k}$}]
at (axis cs:1,17) {};
\node[coordinate,pin=right:{$v_{g}=\frac{d\omega}{dk}$}]
at (axis cs:2.5,30) {};
\node[coordinate,pin=left:{dispersion relation}]
at (axis cs:4.5,47) {};
\end{axis}
\end{tikzpicture}
\caption{Wave dispersion relation with phase and group velocity}
\label{fig:2}
\end{figure}
我想做的是删除 xy 刻度标签,以便我们只保留 xy 标题。我该如何获得它?
答案1
将xtick
和设置ytick
为\empty
,即
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
minor tick num=1,
axis x line=middle,
axis y line=middle,
xlabel=$k$,
ylabel=$\omega$,
ymin=0,xmin=-2,ymax=60,
xtick=\empty,ytick=\empty]
\addplot[blue,domain=0:5, line width=1.5pt] {x^2+25};
\addplot[orange,domain=0:5,line width=1pt]{3*x+22.75};
\addplot[cyan,domain=0:1.5, line width=1pt,dashed]{18.166*x};
\node[coordinate,pin=right:{$v_{\phi}=\frac{\omega}{k}$}]
at (axis cs:1,17) {};
\node[coordinate,pin=right:{$v_{g}=\frac{d\omega}{dk}$}]
at (axis cs:2.5,30) {};
\node[coordinate,pin=left:{dispersion relation}]
at (axis cs:4.5,47) {};
\end{axis}
\end{tikzpicture}
\end{document}