Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is it possible to fill “symbolic y coords” automatically with the content of a table row? I have many data to plot and it would be very cumbersome and laborious to do it manually.

Best regards

Christoph

share|improve this question
    
I wouldn't use symbolic coordinates in this case, but x expr=\coordindex in combination with xtick=data, xticklabels from table={<table macro>}{<column with labels>}. –  Jake Nov 25 '12 at 21:19

1 Answer 1

up vote 4 down vote accepted

I wouldn't use symbolic coordinates for something like this, because they're much less comfortable to use than "proper" coordinates. You can simply plot the data using x expr=\coordindex and add the labels from the table using xtick=data, xticklabels from table={<table macro>}{<column with labels>}:

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pgfplots, pgfplotstable}

\pgfplotstableread[col sep=comma, header=false]{
      23, Einhaltung der Hygienestandards
      20, Zeitintensität des Programms
      18, Zubereitung des O+G
      16, Lagerung des O+G
      7, Müllentsorgung und Reinigung
      6, Sonstige
      4, Keine Probleme
      4, Abstimmung mit dem Lieferanten/Warennahme/Lieferzeitpunkt
      1, Verteilung des O+G auf die Klassen
      1, Qualität der Lieferung/Lieferung an zwei aufeinanderfolgenden Tagen ist schlecht/bessere Verteilung
      1, Keine Lieferung an allen Schultagen/nach Ferien öfters holpriger Beginn
      1, Auswahl des Obstes
      1, Ausstattung mit Materialien (Schneidebrett)
      1, Anmeldung zum SOP
}\datatable

\begin{document}
\begin{tikzpicture}
  \begin{axis}[
    xbar, %
    y=-1.5cm,%
    bar width=0.5cm,%
    enlarge y limits={abs=0.45cm},
    xlabel={Häufigkeit},%
    yticklabels from table={\datatable}{1},
    ytick=data,%
    yticklabel style={text width=5cm,align=right},%
    nodes near coords,%
    nodes near coords align={horizontal},%
    ]%
    \addplot table [y expr=\coordindex, x=0] {\datatable};
  \end{axis}
\end{tikzpicture}
\end{document}  
share|improve this answer
    
Thank you very much! That solved my problem! –  typokurz Nov 27 '12 at 15:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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