基于如何在 pgfplot 中绘制直到与绘图线相交?我想出了这个:
\documentclass{memoir}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{intersections, calc}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\begin{axis}[ymin=0,ymax=100,xmin=5E-13,xmax=3E-4,
xlabel=Concentration,
ylabel=Effect (\%),
axis lines=left,
width=2\marginparwidth,
height=1.4\marginparwidth,
ytick={0,25,50,75,100},
xmode = log,
tick label style = {font=\footnotesize},
]
\addplot [color=black, name path=P] coordinates {
(1E-4, 0)
(1E-5, 0)
(1E-6, 2)
(1E-7, 21)
(1E-8, 66)
(1E-9, 88)
(1E-10, 94)
(1E-11, 95)
(1E-12, 96)
};
\addplot [only marks] coordinates {
(1E-4, 0)
(1E-5, 0)
(1E-6, 2)
(1E-7, 21)
(1E-8, 66)
(1E-9, 88)
(1E-10, 94)
(1E-11, 95)
(1E-12, 96)
};
\path [name path=A] (axis cs:1E-12, 50) -- (axis cs:1E-4, 50);
\path [name intersections={of=A and P}];
\draw[->, thick] (axis cs:1E-12, 50) -- (intersection-1);
\path [name path=B] (axis cs:1E-12, 0) -- (axis cs:1E-4, 0);
\draw[->, thick] (intersection-1) -| B);
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
但是,我想从最后一个箭头的末端向下绘制另一个箭头,直到 x 轴。我以为这很容易,但似乎并非如此。显然,我无法像-|
我尝试的那样在事物之间画一条线。我该怎么办?
答案1
垂直坐标系的工作;你可以这样说
\draw[->, thick,red] (intersection-1) -- ({intersection-1}|-{axis cs:0,0});
完整示例:
\documentclass{memoir}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{intersections, calc}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\begin{axis}[ymin=0,ymax=100,xmin=5E-13,xmax=3E-4,
xlabel=Concentration,
ylabel=Effect (\%),
axis lines=left,
width=2\marginparwidth,
height=1.4\marginparwidth,
ytick={0,25,50,75,100},
xmode = log,
tick label style = {font=\footnotesize},
]
\addplot [color=black, name path=P] coordinates {
(1E-4, 0)
(1E-5, 0)
(1E-6, 2)
(1E-7, 21)
(1E-8, 66)
(1E-9, 88)
(1E-10, 94)
(1E-11, 95)
(1E-12, 96)
};
\addplot [only marks] coordinates {
(1E-4, 0)
(1E-5, 0)
(1E-6, 2)
(1E-7, 21)
(1E-8, 66)
(1E-9, 88)
(1E-10, 94)
(1E-11, 95)
(1E-12, 96)
};
\path [name path=A] (axis cs:1E-12, 50) -- (axis cs:1E-4, 50);
\path [name intersections={of=A and P}];
\draw[->, thick] (axis cs:1E-12, 50) -- (intersection-1);
\draw[->, thick,red]
(intersection-1) -- ({intersection-1}|-{axis cs:0,0});
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}