4

I have written the following code:

\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}

which produces the following output: enter image description here Is it possible to move the the expected return,$\mathbb{E}[R_i]$ and standard deviation, \sigma_i to the end of the axes (being at the end of the arrowheads of the axis lines)?

Thanks in advance!

1 Answer 1

3
\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}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .