我有以下两张 TikZ 图片(见底部的代码)。如何才能使第二张图片(函数图)中的轴样式与第一张图片中的相同?
\documentclass{amsart}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgffor}
\begin{document}
\begin{tikzpicture}[scale=1]
\draw[->] (-0.3,0) -- (7,0);
\draw (8,0) node[below] {$\gamma$};
\draw[->] (0,-0.3) -- (0,5) node[left] {$b_{1+\gamma}$};
\draw (2,.1) -- (2,-.1) node[below] {$p(\rho)-1$};
\draw[dashed] (2,0) -- (2,1.8);
\draw[dashed] (0,2) -- (2,2);
\draw (-.1,2) -- (.1,2) node[left] {$b_\#(\rho)\;$};
\draw (6,.1) -- (6,-.1) node[below] {$1$};
\draw (-0.1,1) -- (0.1,1) node[left] {$b_2\;$};
\draw (0,3.5) .. controls (2,1.8) and (3,1.2) .. (6,1);
\draw[dashed] (0,1) -- (6,1);
\fill[color=white] (0,3.5) circle (3pt);
\draw[color=black] (0,3.5) circle (3pt);
\fill[color=black] (0,4.3) circle (3pt) node[left] {$b_\ast$};
\end{tikzpicture}
\medskip
\begin{tikzpicture}
\begin{axis}[domain = 0:1, samples = 100]
\addplot[color = black] {pi/(((pi/2)+atan(x/sqrt(1-x^2))*pi/180)};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
添加axis lines=center
到轴选项。您还可以添加axis line style={shorten >=-10pt, shorten <=-10pt}
以使轴稍微延伸一点(通过10pt
),这样图就不会触及箭头尖端。
为了改变箭头尖,您可以加载arrows.meta
然后添加-{>}
一个简单的箭头尖。
输出
代码
\documentclass{amsart}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgffor}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\begin{axis}[domain=0:1,samples = 100, axis lines=center, axis line style={shorten >=-10pt, shorten <=-10pt,-{>}}, ymin=0.6,ytick={0.8,1,...,2}]
\addplot[color = black] {pi/(((pi/2)+atan(x/sqrt(1-x^2))*pi/180)};
\end{axis}
\end{tikzpicture}
\end{document}