仅标记一个刻度标记,但 x 轴上有其他刻度标记

仅标记一个刻度标记,但 x 轴上有其他刻度标记

提供的代码让 pgfplots 在 x 轴上标记 5 个刻度线(从 5 开始,以 5 为增量)。我只想标记一个额外的刻度线 - 即 2 处的刻度线。

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}


\begin{document}

\begin{tikzpicture}
\begin{axis}[width=5in,axis on top,clip=false,
    axis lines=middle,
    xmin=-2,xmax=27,
    domain=-2:27,
    xlabel=$x$,ylabel=$y$,
    ymin=-100,ymax=3200,
    restrict y to domain=-100:3200,
    enlargelimits={abs=0.5cm},
    axis line style={latex-latex},
    ticklabel style={font=\tiny,fill=white},
    xtick={\empty},ytick={},
    extra x ticks={5, 10, 15, 20, 25},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]
\addplot[samples=501,domain=0.025574:25,blue] {5*x^2 + 80 / x} node[anchor=west,pos=0.75,font=\footnotesize]{$y = 5x^{2} + \dfrac{80}{x}$};
\draw [fill] (2,60) circle [radius=1.5pt];
\end{axis}
\end{tikzpicture}

\end{document}

答案1

xtick={5,10,...,25},
xticklabels={},
extra x ticks={2},
extra x tick style={xticklabel=\pgfmathprintnumber{\tick}}

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}


\begin{document}

\begin{tikzpicture}
\begin{axis}[width=5in,axis on top,clip=false,
    axis lines=middle,
    xmin=-2,xmax=27,
    domain=-2:27,
    xlabel=$x$,ylabel=$y$,
    ymin=-100,ymax=3200,
    restrict y to domain=-100:3200,
    enlargelimits={abs=0.5cm},
    axis line style={latex-latex},
    ticklabel style={font=\tiny,fill=white},
    xtick={5,10,...,25},
    xticklabels={},
    extra x ticks={2},
    extra x tick style={xticklabel=\pgfmathprintnumber{\tick}},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]
\addplot[samples=501,domain=0.025574:25,blue] {5*x^2 + 80 / x} node[anchor=west,pos=0.75,font=\footnotesize]{$y = 5x^{2} + \dfrac{80}{x}$};
\draw [fill] (2,60) circle [radius=1.5pt];
\end{axis}
\end{tikzpicture}

\end{document}

相关内容