Skip to content

Instantly share code, notes, and snippets.

@TorbjornT
Created July 12, 2018 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TorbjornT/582ba77168ee6c31011fc6c9a6a5b9c6 to your computer and use it in GitHub Desktop.
Save TorbjornT/582ba77168ee6c31011fc6c9a6a5b9c6 to your computer and use it in GitHub Desktop.
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{mathtools}
\newcommand{\LHS}[2][1.5em]{\hspace{#1}\mathllap{#2}}
\newcommand{\RHS}[2][1.5em]{\mathrlap{#2}\hspace{#1}} % moved \hspace after mathrlap
\begin{document}
\begin{tikzpicture}
\begin{axis}[
legend cell align=left,
legend style={legend pos=north west}
]
% added colours to plots
\addplot[blue,domain=0:2] {x^2};
\addplot[red,domain=0:4] {x};
\addplot[red,domain=0:4] {x};
\legend{%
$\LHS{yy}=\RHS[2em]{x^2}$ text,
$\LHS{zty}=\RHS[2em]{xxxx}$ text,
$\LHS{y}=\RHS[2em]{x}$ text,
}
\end{axis}
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment