I've got a problem with tikzpicture. I've made my cv in Latex but one thing isn't working fine. The first graph should look like the other ones. If I remove the enlarge y limit={abs=1cm}, the graph will have multiple entries which appear twice. But Here's the code. Thank you in advance.

\begin{center}

\begin{tikzpicture}[thick,scale=0.8, every node/.style={scale=0.8},every node/.style={font=\sffamily}]
\begin{axis}[title  = \textbf{Sprachen},
xbar,
y axis line style = { opacity = 0 },
axis x line       = none,
tickwidth         = 0pt,
enlarge y limits={abs=1cm},
enlarge x limits  = 0.02,
symbolic y coords = { Französisch, Englisch, Deutsch},
%nodes near coords,
xmin=0,
xmax=1,
]
\addplot coordinates { 
    (1,Deutsch)
    (0.65,Englisch)
    (0.3,Französisch)
};

%\legend{Topics}
\end{axis}
\node[text width=3cm] at (1.5,-0.5) 
{Grundkennt.};
\node[text width=3cm] at (5.25,-0.5) 
{gut};
\node[text width=3cm] at (7.4,-0.5) 
{sehr gut};
\draw (2.5,0.1) -- (2.5, 5.5);
\draw (5,0.1) -- (5, 5.5);
\end{tikzpicture}
\end{center}

Example

edit to explain better the problem:

The following MWE:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}\pgfplotsset{compat=1.13}
\begin{document}

\begin{center}

\begin{tikzpicture}[thick,scale=0.8, every node/.style={scale=0.8},every node/.style={font=\sffamily}]
\begin{axis}[title  = \textbf{Sprachen},
xbar,
y axis line style = { opacity = 0 },
axis x line       = none,
tickwidth         = 0pt,
enlarge x limits  = 0.02,
symbolic y coords = {Französisch, Englisch, Deutsch},
%nodes near coords,
xmin=0,
xmax=1,
]
\addplot coordinates { 
    (1,Deutsch)
    (0.65,Englisch)
    (0.3,Französisch)
};

%\legend{Topics}
\end{axis}
\node[text width=3cm] at (1.5,-0.5) 
{Grundkennt.};
\node[text width=3cm] at (5.25,-0.5) 
{gut};
\node[text width=3cm] at (7.4,-0.5) 
{sehr gut};
\draw (2.5,0.1) -- (2.5, 5.5);
\draw (5,0.1) -- (5, 5.5);
\end{tikzpicture}
\end{center}
\end{document}

has duplicated vertical entries:

enter image description here

...and the things seems corrected by adding

enlarge y limits={abs=1cm}, 

but with spurious vertical space --- what happens?

  • You can define default settings with \pgfplotsset. – user10274 Jun 3 '16 at 14:07
up vote 3 down vote accepted

You can use y=1cm to set the distance between the symbolic coords. The node current axis can be used to draw the black lines. Additionally I would trim the plots on the left side so that the bars are all left aligned.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}% loads also tikz
\pgfplotsset{compat=1.13}

\tikzset{
  mycvplot/.style={
    thick,
    scale=.8,
    nodes={scale=.8,font=\sffamily},
    trim left=-4em,
    /pgfplots/every axis/.append style={
      xbar,
      axis line style={draw=none},
      tickwidth=0pt,
      enlarge x limits=.05,
      xmin=0,xmax=1,
      xtick={.15,.52,.92},
      xticklabels={Grundkennt.,gut,sehr gut,},
      y=1cm,
      enlarge y limits={abs=.5cm},
      ytick=data,
      title style={at={(.52,1)}}
    }
  }
}

\newcommand\cvplotlines{
  \foreach \x in {2.5,5}
    \draw (\x,0|-current axis.south) -- (\x,0|-current axis.north);
}

\usepackage{showframe}% to show the page layout
\begin{document}

\begin{center}
\begin{tikzpicture}[mycvplot]
  \begin{axis}[
      title  = \textbf{Sprachen},
      symbolic y coords = {Französisch, Englisch, Deutsch},
    ]
    \addplot coordinates { 
        (1,Deutsch)
        (0.65,Englisch)
        (0.3,Französisch)
    };
  \end{axis}
  \cvplotlines
\end{tikzpicture}
\end{center}

\begin{center}
\begin{tikzpicture}[mycvplot]
  \begin{axis}[
      title  = \textbf{Programmiersprachen},
      symbolic y coords = {HTML/JavaScript,S,C\#,C,\LaTeX,Python},
    ]
    \addplot coordinates { 
        (1,Python)
        (1,\LaTeX)
        (0.65,C)
        (0.65,C\#)
        (0.65,S)
        (0.3,HTML/JavaScript)
    };
  \end{axis}
  \cvplotlines
\end{tikzpicture}
\end{center}
\end{document}

Result:

enter image description here

  • Cool stuff. I thank you very much! – Michael Jun 4 '16 at 15:18

The double ticks can be removed by adding ytick=data to your options. The large spacing is because the bars are distributed evenly to fill the plot height. Adding additional entries demonstrates this.

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}\pgfplotsset{compat=1.13}
\begin{document}

\begin{center}

\begin{tikzpicture}[thick,scale=0.8, every node/.style={scale=0.8},every node/.style={font=\sffamily}]
\begin{axis}[title  = \textbf{Sprachen},
xbar,
y axis line style = { opacity = 0 },
axis x line       = none,
tickwidth         = 0pt,
enlarge x limits  = 0.02,
symbolic y coords = {Französisch, Englisch, Deutsch},
ytick=data,
%nodes near coords,
xmin=0,
xmax=1,
]
\addplot coordinates { 
    (1,Deutsch)
    (0.65,Englisch)
    (0.3,Französisch)
};

%\legend{Topics}
\end{axis}
\node[text width=3cm] at (1.5,-0.5) 
{Grundkennt.};
\node[text width=3cm] at (5.25,-0.5) 
{gut};
\node[text width=3cm] at (7.4,-0.5) 
{sehr gut};
\draw (2.5,0.1) -- (2.5, 5.5);
\draw (5,0.1) -- (5, 5.5);
\begin{scope}[xshift=10cm]
\begin{axis}[title  = \textbf{Sprachen},
xbar,
y axis line style = { opacity = 0 },
axis x line       = none,
tickwidth         = 0pt,
enlarge x limits  = 0.02,
symbolic y coords = {Japanisch, Rumänisch, Französisch, Englisch, Deutsch},
ytick=data,
%nodes near coords,
xmin=0,
xmax=1,
]
\addplot coordinates { 
    (1,Deutsch)
    (0.65,Englisch)
    (0.3,Französisch)
    (0.2,Rumänisch)
    (0.1,Japanisch)
};

%\legend{Topics}
\end{axis}
\node[text width=3cm] at (1.5,-0.5) 
{Grundkennt.};
\node[text width=3cm] at (5.25,-0.5) 
{gut};
\node[text width=3cm] at (7.4,-0.5) 
{sehr gut};
\draw (2.5,0.1) -- (2.5, 5.5);
\draw (5,0.1) -- (5, 5.5);
\end{scope}

\end{tikzpicture}
\end{center}
\end{document}
  • Okay, I understand this but how could I change the height only in this case? After this graph another graphs appear in the cv. If I decrease the height with pgfplotset this will change all plot. Does somebody know a hint? – Michael Jun 3 '16 at 16:40
  • 1
    height and width can be specified locally to each axis environment. (You have to specify both if you want to change just one, otherwise the other is scaled accordingly). So for example add height=4cm, width=9cm, into the axis environment options – Rmano Jun 3 '16 at 16:58

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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