1

I'm trying to add an arrow in the legend entries of the following pic:

enter image description here

which I obtained with the following code:

\begin{figure}[hbt!]
\centering
\begin{tikzpicture}[scale=0.9]
\begin{axis}[xmin=1,xmax=10, xlabel=q,smooth, legend entries={$CSSD01 - SHGN$,$SHGN - 
     CSSD01$},legend pos=north west]
    \addplot+[black] coordinates{(1,0) (2,0.01290066) (3,0.01558624) (4,0.02803845) (5,0.03660804) 
(6,0.03881025) (7,0.04132278) (8,0.04367998) (9,0.04028380) (10,0.05604479)};
    \addplot+[blue] coordinates{(1,0) (2,0) (3,0.0007861957) (4,0.0058689934) (5,0.0080498249) 
(6,0.0092150462) (7,0.0271291580) (8,0.0057372855) (9,0.0068062622) (10,0)};
    \end{axis}
\end{tikzpicture}
\end{figure}

I would like to substitute the dash in legend entries with an arrow from the left to the right, e.g.:

legend entries={$CSSD01 \to SHGN$,$SHGN \to CSSD01$}

but in this case I obtained an error. How could I fix this problem?

Torbjørn T.
  • 206,688
Mark
  • 755

1 Answers1

1

Don't know what exactly happens, but \rightarrow works, i.e.

legend entries={$CSSD01\rightarrow SHGN$,$SHGN \rightarrow CSSD01$}
Torbjørn T.
  • 206,688
  • 1
    pgfplots uses \to in some macro definitions, e.g. pgfplotsticks.code.tex: \pgfplots@transform@csv@list{#1}\to{#3}\with{..., so possibly this is why it gets confused by a \to here. That is, using \rightarrow is the correct choice. –  Mar 30 '21 at 12:27