5

I want to produce a comparison graph chart like this: enter image description here

I have found information about bar graphs, but not about line comparison graphs as I am trying to do. Any help?. Thanks.

0

1 Answer 1

5

Such plots are called comb plots and they are described in detail in section 4.5.7 Comb Plots of the pgfplots manual (v 1.16). Since I do not have your data, I copied the example from there, and modified the coordinates of the second plot slightly, and also introduced a nontrivial dash pattern.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture} 
\begin{axis}
    \addplot+ [line width=1pt,
        ycomb,
    ] coordinates {
        (0,3) (1,2) (2,4) (3,1) (4,2)
    };
    \addplot+ [line width=1pt,dash pattern=on 4pt off 1pt on 2pt off 1pt,
        ycomb,
    ] coordinates {
        (0,3.4) (1,1.8) (2,4.2) (3,1.2) (4,1.6)
    };
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

2
  • Thank you so much. I could find such plots in the section 4.4.6 of the Manual: tools.ietf.org/doc/texlive-doc/latex/pgfplots/pgfplots.pdf
    – Alfredo
    Dec 26, 2018 at 17:35
  • @Alfredo Yes, because you're looking at the 2011 version of the manual. My statement refers to the current version (1.16), and I should probably mentioned this explicitly.
    – user121799
    Dec 26, 2018 at 17:37

You must log in to answer this question.

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