0

I have the following code:


\begin{tikzpicture}
    
\begin{axis}[legend style={at={(0.5,-0.1)},anchor=north}]
        
\addplot {x};
        
\addlegendentry{$x$}
        
\addplot {x^2};
        
\addlegendentry{$x^2$}
    
\end{axis}

\end{tikzpicture}

Unfortunately, as you can see in the picture, the legend text isnt at the same height as the legend line.

Do you know how to fix it?

Thank u very much! Andre

enter image description here

4
  • Welcome to TSE. Please post a Minimal Working Example, instead of a code snippet. Jul 28 at 11:01
  • 1
    I can't reproduce your problem. I get legend with text and symbols correct aligned.
    – Zarko
    Jul 28 at 11:59
  • i used: \pgfplotsset{compat=1.11, every axis legend/.style={ y tick label style={/pgf/number format/1000 sep=}, x tick label style={/pgf/number format/1000 sep=}}}
    – Andre
    Jul 28 at 13:05
  • 1
    And what should this be good for? If you really should need it, replace .style by .append style. (By that you also get back the frame around the legend.) Jul 28 at 14:16
0

First of all thank u all for the fast respond :)

i probably found the problem: I used this code in \pgfplotsset{...}:

every axis legend/.style={
y tick label style={/pgf/number format/1000 sep=},                  
x tick label style={/pgf/number format/1000 sep=}}}    

if i deactivate that, the legend is at a same height. BUT then i have another problem: my Legend is now framed, which i do not want. Does anybody know how to fix that? :D

2
  • 1
    Welcome to TSE. That is another question. I suggest that you post it as such. Jul 28 at 13:30
  • 1
    To remove the frame from the legend, add option legend style={draw=none} to the axis options or use \pgfplotsset{legend style={draw=none}} in the preamble.
    – esdd
    Jul 28 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.