1

I have the following chart yet the blue bar doesn't display correct:

\begin{tikzpicture} 
 \begin{semilogyaxis}[ybar,   xticklabels={{2}, {10}, {28}, {112}, {224}, {392}}, xtick = {2, 4, 6, 8, 10, 12},
         width = 0.45*\textwidth,
         xtick style={draw=none},
         ymajorgrids=true,
         ylabel={Transmission Speed (kbps)}, 
         xlabel={Message Size}, xticklabel style={rotate=90},]
\addplot [draw=blue,pattern color = blue, pattern = north west lines]
                coordinates {(2, 473000)};
\addplot [draw=red,pattern color = red, pattern = north west lines]
                coordinates {(4, 88500)};
\addplot [draw=green,pattern color = green, pattern = north west lines]
                coordinates {(6, 2320)};
\addplot [draw=yellow,pattern color = yellow, pattern = north west lines]
                coordinates {(8, 1160)};
\addplot [draw=black,pattern color = black, pattern = north west lines]
                coordinates {(10, 251)};
\addplot [draw=black,pattern color = black, pattern = north east lines]
                coordinates {(12, 164)};   
\end{semilogyaxis}
\end{tikzpicture}

I can't see why the 2, 473000 coordinates are missing.

  • @StefanPinnow Kind of duplicate, I think I didn't stumble across that because the question doesn't ask about missing bars. – Dean Jan 19 '18 at 8:40
  • That's true, but duplicates here on TeX.SX normally refer to the answers and not necessarily to the question. And in that answer it is also given that bar shift=0pt solved the issue. Nonetheless: esdd has given the answer ;) – Stefan Pinnow Jan 19 '18 at 8:42
2

You have multiple bar plots inside one axis environment. So there could be more than one bar for a x value. So the bars for each plot are shifted a bit to not overlap each other.

But it seems that you do not want/need this shift. So you could set bar shift=0pt as axis option:

\documentclass[margin=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture} 
 \begin{semilogyaxis}[ybar,   xticklabels={{2}, {10}, {28}, {112}, {224}, {392}}, xtick = {2, 4, 6, 8, 10, 12},
         width = 0.45*\textwidth,
         xtick style={draw=none},
         ymajorgrids=true,
         ylabel={Transmission Speed (kbps)}, 
         xlabel={Message Size}, xticklabel style={rotate=90},
          bar shift=0pt% <- added
         ]
\addplot [draw=blue,pattern color = blue, pattern = north west lines]
                coordinates {(2, 473000)};
\addplot [draw=red,pattern color = red, pattern = north west lines]
                coordinates {(4, 88500)};
\addplot [draw=green,pattern color = green, pattern = north west lines]
                coordinates {(6, 2320)};
\addplot [draw=yellow,pattern color = yellow, pattern = north west lines]
                coordinates {(8, 1160)};
\addplot [draw=black,pattern color = black, pattern = north west lines]
                coordinates {(10, 251)};
\addplot [draw=black,pattern color = black, pattern = north east lines]
                coordinates {(12, 164)};   
\end{semilogyaxis}
\end{tikzpicture}
\end{document}

enter image description here

| improve this answer | |

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