绘制垂直图

绘制垂直图

有没有用 pgf-plots 快速绘制垂直图的方法?我需要为下面的图绘制连续的垂直线:

\begin{center}
\begin{tikzpicture}
\begin{axis}[
clip=false,
ylabel={},
xlabel=$$,
axis lines=middle,
xticklabels={},% if you don't want x tick labels
yticklabels={},% if you don't want y tick labels
xtick=\empty,% if you don't want x ticks
ytick=\empty,% if you don't want y ticks
extra x ticks={},
extra x tick labels={$\color{red}\bar{p}$,1.2},
extra tick style={major tick length=5pt, tick style={red, line width=0.1em}},
]

\addplot[domain=-0:2, samples=200, black, ultra thick] plot(\x,{-1+(1/\x^(1/3))});
\addplot[domain=-0:2, samples=200, black, ultra thick] plot(\y,{0.5});
\end{axis}
\end{tikzpicture}
\end{center}

谢谢。

答案1

绘制垂直线的一种方法pgfplots是指定两个坐标:

在此处输入图片描述

代码:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}
    \addplot [red, dotted, thick] coordinates {(2,-1) (2,1)}
        node [right] {$x=2$};
\end{axis}
\end{tikzpicture}
\end{document}

相关内容