4

I want to use a Block diagram like in this document on page 9: http://texdoc.net/texmf-dist/doc/generic/pst-bar/pst-bar-docDE.pdf

But I fail at doing this.
At the moment I am using this: Grouped bar chart

\definecolor{bblue}{HTML}{4F81BD}
\definecolor{rred}{HTML}{C0504D}
\definecolor{ggreen}{HTML}{9BBB59}

\begin{figure}[h]
\begin{tikzpicture}
\begin{axis}[
    width  = 0.85*\textwidth,
    height = 8cm,
    major x tick style = transparent,
    ybar=2*\pgflinewidth,
    %ybar stacked,
    bar width=14pt,
    ymajorgrids = true,
    ylabel = {Zeit in Sekunden},
    symbolic x coords={lokal,1 Gerät, 2 Geräte},
    xtick = data,
    scaled y ticks = false,
    enlarge x limits=0.25,
    ymin=0,
    nodes near coords,
    legend cell align=left,
    legend style={
            at={(1,1.05)},
            anchor=south east,
            column sep=1ex
    }
]
    \addplot[style={bblue,fill=bblue,mark=none}]
         coordinates {(lokal,973) (1 Gerät,1426) (2 Geräte,698)};
    \addplot[style={rred,fill=rred,mark=none}]
        coordinates {(lokal, 0.0) (1 Gerät,6.00) (2 Geräte,5.1)};
    \addplot[style={ggreen,fill=ggreen,mark=none}]
        coordinates {(lokal,52) (1 Gerät,276) (2 Geräte,169)};

    \legend{Durchschnittliche Zeit zur Berechneung,Durchschnittliche Zeit zur Verteilung,Streuung gesamte Zeit}
\end{axis}
\end{tikzpicture}
\end{figure}

I want the diagram to be "block" style.
Alternatively I could draw a cross to show the Range of the results.
I need the horizontal line to be the average and the vertical line to be the range from minimum to maximum value. I have no idea what packages, or command I have to use, to get what I want, so any recommendation is appreciated.

  • 1
    I would suggest you take a look at the source. This is included in the TeX distribution, as far as I can tell. It should be in the same path, just with source instead of doc as a DTX file. (And welcome to TeX.SX!) – Sean Allred Jul 10 '13 at 11:49
  • Also, we usually don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. – Sean Allred Jul 10 '13 at 11:50
  • @naturjoghurt Hi there! I'm not sure what is the problem you have, and you say nothing whether your code is working or not. I guess the simplest answer to your concern is that pst is not compatible with PDF (I don't know if your compiling with pdflatex) and also is independent of TikZ. Perhaps you can try to emulate the "block" style with TikZ. Is that what you want? – Dox Jul 10 '13 at 12:12
  • @naturjoghurt Can you explain (in English) how does the block style of pstworks? – Dox Jul 10 '13 at 12:19
  • @Dox Yes, I am compiling with pdflatex. That is why pst did not work for me. The "block" style is used to display multiple values in one bar. The beginning and end of any bar can be adjusted, instead of just adjusting the height. With this style I want to show the minimum, maximum and range of my results. The minimum and maximum define the end and beginning of each bar and the range is the length of each bar. This way the values could be compared better, than using multiple bars. – Naturjoghurt Jul 10 '13 at 12:24
4

run with xelatex

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pst-bar}
\usepackage{filecontents}

\begin{filecontents*}{example.csv}
lokal, 1 Gerät, 2 Geräte
973, 1426, 698
0, 6, 5.1
52, 276, 169
\end{filecontents*}

\begin{document}

\psset{xunit=0.5in,yunit=0.5}
\begin{pspicture}(-1,-1.5)(3,15.5)
\psgrid[xunit=1.5in,gridlabels=0,subgriddiv=0,griddots=30](0,0)(1,15)
\psaxes[axesstyle=frame,dy=3,Dy=300,labels=y,ticks=y](0,0)(3,15)
\readpsbardata{\data}{example.csv}
\psbarchart[barstyle=red,chartstyle=block,yunit=0.01]{\data}
\end{pspicture}

\end{document}

or with pdflatex --shellescape <file> use

[...]
\usepackage{pst-bar}
\usepackage{auto-pst-pdf}
[...]

enter image description here

  • Seems to be the right solution, but when I compile this with XeLatex I get some Errors: ! Package inputenc Error: Keyboard character used is undefined ! Package inputenc Error: Unicode char \u8:ätD not set up for use with LaTeX. And so on. I do not get these when compiling with Latex and letting the graphic out. Any idea, why I get these Errors when compiling with XeLatex? – Naturjoghurt Jul 10 '13 at 14:31
  • 1
    with xelatexyou have to delete the line with inputenc it is by default utf8 and the one with fontenc. Use instead \usepackage{fontspec} – user2478 Jul 10 '13 at 14:34
  • That solved the Problem. This is the right answer for my Problem, but the look of the XeLatex output is different. – Naturjoghurt Jul 10 '13 at 14:44
  • I get the same one. – user2478 Jul 10 '13 at 14:47

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.