![轴末端的刻度](https://linux22.com/image/371396/%E8%BD%B4%E6%9C%AB%E7%AB%AF%E7%9A%84%E5%88%BB%E5%BA%A6.png)
我写了以下代码:
\documentclass{article}
\usepackage{amssymb}
\usepackage[margin=0.5in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[dvipsnames]{xcolor}
\usepackage{pgfplots}
\pgfplotsset{width=12cm,compat=1.9}
\begin{document}
\begin{figure}[ht]
\centering
\begin{tikzpicture}[scale=1]
\begin{axis}[
xlabel = {$\sigma_i$},
ylabel = {$\mathbb{E}[R_i]$},
axis x line=bottom,
axis y line=left,
xmin=0,xmax=5.5,
legend cell align={left},
xtick=\empty,
ytick={1.38,2.38,3.38},
yticklabels={$U_1$,$U_2$,$U_3$},
axis line style = thick,
domain=0:7.5,
samples=1000
]
\addplot [very thick,color=Black,]
{2*x^0.5 - 0.2*x};
\addlegendentry{Efficient frontier};
\addplot [very thick,color=Gray,dash pattern=on 10pt off 2pt on 10pt off 2pt,]
{0.02*x^3 + 3.38};
\addlegendentry{Utility curves};
\addplot [very thick,color=Gray,dash pattern=on 10pt off 2pt on 10pt off 2pt,]
{0.02*x^3 + 2.38};
\addplot [very thick,color=Gray,dash pattern=on 10pt off 2pt on 10pt off 2pt]
{0.02*x^3 + 1.38};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
输出结果如下:
是否可以将预期回报
$\mathbb{E}[R_i]$
和标准差移动\sigma_i
到轴的末端(位于轴线箭头的末端)?
提前致谢!
答案1
\begin{figure}[ht]
\centering
\begin{tikzpicture}[scale=1]
\begin{axis}[
xlabel = {$\sigma_i$},
ylabel = {$\mathbb{E}[R_i]$},
axis x line=bottom,
axis y line=left,
xmin=0,xmax=5.5,
legend cell align={left},
xtick=\empty,
ytick={1.38,2.38,3.38},
yticklabels={$U_1$,$U_2$,$U_3$},
axis line style = thick,
domain=0:7.5,
samples=1000,
% added this
every axis x label/.style={
at={(ticklabel* cs:1.0)},
anchor=north,
},
every axis y label/.style={
at={(ticklabel* cs:1.0)},
anchor=east,
}
]
\addplot [very thick,color=Black,]
{2*x^0.5 - 0.2*x};
\addlegendentry{Efficient frontier};
\addplot [very thick,color=Gray,dash pattern=on 10pt off 2pt on 10pt off 2pt,]
{0.02*x^3 + 3.38};
\addlegendentry{Utility curves};
\addplot [very thick,color=Gray,dash pattern=on 10pt off 2pt on 10pt off 2pt,]
{0.02*x^3 + 2.38};
\addplot [very thick,color=Gray,dash pattern=on 10pt off 2pt on 10pt off 2pt]
{0.02*x^3 + 1.38};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}