我想要从上到下有三条垂直虚线来明显划分 4 个功能。我该怎么做?
\documentclass[letter,12pt,twoside]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines = left,
xlabel = $\beta$,
ylabel = {$E[\pi_B(\beta)]/10^4$},
]
\addplot [
domain=1875/497:4,
samples=100,
color=red
]
{5*(-(1/3) + 5/x)};
\draw[fill] (3.2,4.5) circle (2pt) coordinate (a);
\addplot [
domain=2500/741:1875/497,
samples=100,
color=red
]
{ 50/3 / x};
\addplot [
domain=625/196:2500/741,
samples=100,
color=red
]
{ 5*(1/5 + 5/2/x)};
\addplot [
domain=305/97:625/196,
samples=100,
color=red
]
{ 5*(1/3 + 2/x)};
\end{axis}
\draw[dotted] (1875/497, 4.4) -- (1875/497,5);
\end{tikzpicture}
\end{document}
先感谢您
答案1
很难说什么是“最佳”的方法,但这是一种可能的方法。
\documentclass[border=3.14mm,standalone]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines = left,
xlabel = $\beta$,
ylabel = {$\alpha$},
]
\addplot [
domain=1875/497:4,
samples=100,
color=red
]
{5*(-(1/3) + 5/x)} coordinate[pos=0] (x1);
\addplot [
domain=2500/741:1875/497,
samples=100,
color=red
]
{ 50/3 / x} coordinate[pos=1] (x2);
\draw[dotted] (x1) -- (x2);
\end{axis}
\end{tikzpicture}
\end{document}
答案2
一种解决方案是使用格式为 (axis cs: x,y) 的坐标。这是通用的,您可以在任何地方选择任意两个点。以下是中间一行的代码。您可以用同样的方式添加其他行。
\documentclass[border=3.14mm,standalone]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines = left,
xlabel = $\beta$,
ylabel = {$\alpha$},
]
\addplot [
domain=1875/497:4,
samples=100,
color=red
]
{5*(-(1/3) + 5/x)} ;
\addplot [
domain=2500/741:1875/497,
samples=100,
color=red
]
{ 50/3 / x} ;
\draw[dotted] (axis cs:3.77,0) -- (axis cs:3.77,4.95);
\end{axis}
\end{tikzpicture}
\end{document}