0

I'm trying to create a graph that looks roughly like this

I haven't found a way to do this other than using several single horizontal bar charts. The "heigth" of the bars is only relevant in comparison with their neighbours. Ideally 3-6 bar charts should fit inside with the possibility to plot standard error or standard deviations.

(raw data)

This is the data to be plotted, computational draw in % compared between several units of a node. So a bar could have 1 uniform length (of say 1-2cm) and each bar would then be x% as long as the maximum length, depending on the values provided.

These occur in 3 node or 6 node blocks, but a solution to one can probably be adapted to the other. A standard deviation would be useful on every bar, fixed to the center of a bar's head (like this but rotated right by 90°)

Can this be done with tikz or pgfplots?

  • 99% of the graphs can be madre using tikz-pgf-plots... we only need to be patient. :) – manooooh Oct 24 '18 at 19:14
  • Please edit your question to tells us the following. What does the length of the bars depend on? How do you want the standard deviation be plotted? Is the picture you show exactly what you want or you would like to add more to it? If you would like to add more, could you draw with your hand in the picture to show us roughly what you want? Please make these clear for us to help you. – zyy Oct 24 '18 at 19:28
  • You could do a group plot of xbar charts and add the axes around it afterwards. – user121799 Oct 24 '18 at 19:44
  • @zyy I edited my answer to provide the details you asked about. There should be nothing more to add to the graph other than the explanation of the values and where the standard deviation should go. – bhnn Oct 24 '18 at 19:52
  • 1
    If you provide the data in form of a text (rather than a screen shot) I will give it a try. – user121799 Oct 24 '18 at 20:14
1

I do not follow external links for security reasons. So I just copied an example of a xbar plot from the pgfmanual, but you will find it straightforward to add your own data. And of course I use groupplots, as suggested in my comment.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{patterns,positioning}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{tikzpicture}
  \begin{groupplot}[group style={group size=3 by 1},xmin=0,ymin=0,height=4cm,
  width=5cm,no markers, xbar,hide axis%,xtick=\empty,ytick=\empty
  ]
    \nextgroupplot
         \addplot [draw=black,
        pattern=horizontal lines dark blue,
    ] coordinates {
        (3,5) (5,10) (15,15) (20,20) (35,25)
    };
    \nextgroupplot
         \addplot [draw=black,
        pattern=horizontal lines dark blue,
    ] coordinates {
        (3,5) (5,10) (15,15) (20,20) (35,25)
    };
    \nextgroupplot
         \addplot [draw=black,
        pattern=horizontal lines dark blue,
    ] coordinates {
        (3,5) (5,10) (15,15) (20,20) (35,25)
    };
    \end{groupplot}
    \draw[-latex] ([xshift=-2mm]group c1r1.south west) -- 
     ([xshift=-2mm]group c1r1.north west) 
     node[midway,sloped,above,font=\sffamily] {values};
    \draw[-latex] ([xshift=-2mm]group c1r1.south west) -- (group c3r1.south east)
    node[below,right,font=\sffamily] {nodes};
    \foreach \X in {1,2,3}
    {\node[below=4pt of group c\X r1.south] {\X};}
\end{tikzpicture}
\end{document}

enter image description here

  • I see an error when using compat=1.16, says I can only use 1.14. But it works even with 1.14. Thank you! Is there a way to have the unit names show up as y-axis ticks instead of only having 'values' as an axis label? – bhnn Oct 24 '18 at 21:10
  • @bhnn Yes, it also works with older versions of pgfplots, but if I was you I would update my TeX installation. And of course you can replace "values" by whatever you like, I chose "values" because you have it in your picture. – user121799 Oct 24 '18 at 21:13
  • My bad, hadn't gone over the code closely enough... Adapting the code was simple, just as you said. But the y-axis is still giving me trouble. I tried ytick=data but that doesn't work on hidden axes. Unhiding them breaks the entire look, so that seems out as well. There don't seem to be anchor points well suited as you did for the x-axis. Do you have a suggestion on how to add comp1-5 as y-labels? – bhnn Oct 24 '18 at 21:33
  • 1
    @bhnn Sorry, this is not a TeX support center. You were asking how to draw a diagram of a given shape, and I think I provided a possible way to accomplish this. If you have additional requests, please ask a new question. Asking questions is free. And you will almost certainly get great answers if you post the code showing what you have tried. The purpose of this site is not to provide a hotline for single users, rather to provide solutions and codes for everyone with a similar question. – user121799 Oct 24 '18 at 22:16

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.