4

I created this graph using pgfplots:

enter image description here

As you can see, the bars overlap near 0. How can I solve the problem?

MWE

\documentclass[12pt,a4paper,twoside,openright]{book}

\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{pgfplots}
\pgfplotsset{width=10cm}

\begin{document}
    \begin{tikzpicture}[scale=0.8]
                \begin{axis}[ybar,
                             ymajorgrids=true,
                             xlabel=nodi,ylabel=energia,
                             bar width = 5pt]
                    \addplot [fill=red!50,draw=red!50!black]
                        table [x=nodes,y=bc]
                        {./MATLAB/grafici/energia/broadcast_vs_pure_network_coding/energy_bc_vs_pnc_1e_3_100nodes.txt};
                    \addplot [fill=blue!70, draw=blue!50!black]
                        table [x=nodes,y=pnc]
                        {./MATLAB/grafici/energia/broadcast_vs_pure_network_coding/energy_bc_vs_pnc_1e_3_100nodes.txt};
                \end{axis}
\end{tikzpicture}

\end{document}

Here the data using to make the plot:

nodes   bc          pnc
1       6.7916e-05  6.792e-05
3       6.8753e-05  6.8748e-05
7       7.0441e-05  7.0369e-05
12      7.2541e-05  7.2339e-05
20      7.5999e-05  7.5407e-05
25      7.8128e-05  7.7274e-05
35      8.252e-05   8.0968e-05
50      8.915e-05   8.6421e-05
65      9.5991e-05  9.1831e-05
75      0.00010053  9.5423e-05
90      0.00010756  0.00010082
100     0.00011228  0.00010441
7
  • Can you include a MWE for us to replicate the problem?
    – percusse
    Dec 24, 2012 at 18:26
  • Does it exist a way to get more distance between the bars?
    – Mazzy
    Dec 24, 2012 at 18:45
  • Would it be ok to add x post scale=4,height=6cm to the axis options?
    – percusse
    Dec 24, 2012 at 19:05
  • unfortunately it is to large...it goes out of paper
    – Mazzy
    Dec 24, 2012 at 19:12
  • Your data points are too close initially so there is not much to do other than maybe switching to a scatter plot.
    – percusse
    Dec 24, 2012 at 19:15

1 Answer 1

7

I suppose you should use one of the coordinate filters to get rid of one or more of the offending data points.

A possibility could be

skip coords between index={1,3}

which would skip the coordinates with indices 1 and 2.

You must log in to answer this question.

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