Überarbeitungsverlauf[Zurück]
Klicke auf Einblenden/Ausblenden von Überarbeitungen 2
Beispielhafte Konvertiert von Pseudoantwort zu Frage + Formatierung

07 Jun '18, 08:11

saputello's gravatar image

saputello
11.1k174365

Verwendung von CSV-Daten mit Komma als Spaltentrenner zwischen String-Daten

Ich glaube, Unter »[pgfplots: x-Achse mit Strings](https://texwelt.de/wissen/fragen/22222/pgfplots-x-achse-mit-strings)« habe ich habe es, dank: https://tex.stackexchange.com/questions/63335/pgfplots-using-strings-from-data-table-as-x-axis-labels-in-bar-chart ein Problem mit String-Daten für die *x*-Achse geschildert, das ich mit Hilfe von »[pgfplots using strings *from data table* as x axis labels in bar chart](https://tex.stackexchange.com/questions/63335/pgfplots-using-strings-from-data-table-as-x-axis-labels-in-bar-chart)« lösen konnte: \documentclass{scrartcl} \usepackage{amsmath} \usepackage[normalem]{ulem} \usepackage{tikz} \usepackage{pgfplots} \usepackage{pgfplotstable} \pgfplotsset{compat=newest} \usepgfplotslibrary{dateplot} \usepackage{subcaption} \usepackage{filecontents} \begin{filecontents}{datensuperfein.dat} x,y ETD 29/16/10,9.60 ETD 34/17/11,13.21 ETD 39/20/13,19.92 ETD 44/22/15,29.96 ETD 49/25/16,40.34 PQ 20/20,5.80 PQ 26/20,10.15 PQ 26/25,12.47 PQ 32/20,14.43 PQ 32/30,21.37 \end{filecontents} \pgfplotstableread[col sep=comma]{datensuperfein.dat}\datatable \makeatletter \pgfplotsset{ /pgfplots/flexible xticklabels from table/.code n args={3}{% \pgfplotstableread[#3]{#1}\coordinate@table \pgfplotstablegetcolumn{#2}\of{\coordinate@table}\to\pgfplots@xticklabels \let\pgfplots@xticklabel=\pgfplots@user@ticklabel@list@x } } \begin{document} \begin{figure} \centering \begin{tikzpicture} \begin{axis}[ ybar, ymin=0, xlabel=Xstuff, ylabel=Value, flexible xticklabels from table={datensuperfein.dat}{x}{col sep=comma}, xticklabel style={text height=1.5ex}, % To make sure the text labels are nicely aligned xtick=data, nodes near coords, nodes near coords align={vertical}] \addplot table[x expr=\coordindex,y=y]{\datatable}; \end{axis} \end{tikzpicture} \caption{Caption} \end{figure} \end{document} Dazu nur ein paar Fragen: Ich verstehe nicht so ganz, warum > \pgfplotstableread[col > \pgfplotstableread[col sep=comma]{datensuperfein.dat}\datatable bereits in der Preambel Präambel geladen werden muss. Das erscheint mir etwas unlogisch, gehört das doch eigentlich nur zu einem einzigen Graphen. Was, wenn ich jetzt mehrer mehrere Graphen erstelle, mit unterschiedlichen x-Labels, müssen die Einstellungen alle in die Preambel? Präambel? Gibt es eine Möglichkeit, alle relevanten Einstellung direkt in zwischen \begin{tikzpicture} `\begin{tikzpicture}` und \end{tikzpicture} `\end{tikzpicture}` einzubinden um eine gewissen Übersichtlichkeit zu wahren (spric (sprich diese Einstellung gehört exakt zu diesem einen Graph). Danke. \documentclass{scrartcl} \usepackage{amsmath} \usepackage[normalem]{ulem} \usepackage{tikz} \usepackage{pgfplots} \usepackage{pgfplotstable} \pgfplotsset{compat=newest} \usepgfplotslibrary{dateplot} \usepackage{subcaption} \usepackage{filecontents} \begin{filecontents}{datensuperfein.dat} x,y ETD 29/16/10,9.60 ETD 34/17/11,13.21 ETD 39/20/13,19.92 ETD 44/22/15,29.96 ETD 49/25/16,40.34 PQ 20/20,5.80 PQ 26/20,10.15 PQ 26/25,12.47 PQ 32/20,14.43 PQ 32/30,21.37 \end{filecontents} \pgfplotstableread[col sep=comma]{datensuperfein.dat}\datatable \makeatletter \pgfplotsset{ /pgfplots/flexible xticklabels from table/.code n args={3}{% \pgfplotstableread[#3]{#1}\coordinate@table \pgfplotstablegetcolumn{#2}\of{\coordinate@table}\to\pgfplots@xticklabels \let\pgfplots@xticklabel=\pgfplots@user@ticklabel@list@x } } \begin{document} \begin{figure} \centering \begin{tikzpicture} \begin{axis}[ ybar, ymin=0, xlabel=Xstuff, ylabel=Value, flexible xticklabels from table={datensuperfein.dat}{x}{col sep=comma}, xticklabel style={text height=1.5ex}, % To make sure the text labels are nicely aligned xtick=data, nodes near coords, nodes near coords align={vertical}] \addplot table[x expr=\coordindex,y=y]{\datatable}; \end{axis} \end{tikzpicture} \caption{Caption} \end{figure} \end{document} Graph)?
Klicke auf Einblenden/Ausblenden von Überarbeitungen 1

06 Jun '18, 11:47

SF6's gravatar image

SF6
15953440

Ich glaube, ich habe es, dank: https://tex.stackexchange.com/questions/63335/pgfplots-using-strings-from-data-table-as-x-axis-labels-in-bar-chart Dazu nur ein paar Fragen: Ich verstehe nicht so ganz, warum > \pgfplotstableread[col > sep=comma]{datensuperfein.dat}\datatable bereits in der Preambel geladen werden muss. Das erscheint mir etwas unlogisch, gehört das doch eigentlich nur zu einem einzigen Graphen. Was, wenn ich jetzt mehrer Graphen erstelle, mit unterschiedlichen x-Labels, müssen die Einstellungen alle in die Preambel? Gibt es eine Möglichkeit, alle relevanten Einstellung direkt in zwischen \begin{tikzpicture} und \end{tikzpicture} einzubinden um eine gewissen Übersichtlichkeit zu wahren (spric diese Einstellung gehört exakt zu diesem einen Graph). Danke. \documentclass{scrartcl} \usepackage{amsmath} \usepackage[normalem]{ulem} \usepackage{tikz} \usepackage{pgfplots} \usepackage{pgfplotstable} \pgfplotsset{compat=newest} \usepgfplotslibrary{dateplot} \usepackage{subcaption} \usepackage{filecontents} \begin{filecontents}{datensuperfein.dat} x,y ETD 29/16/10,9.60 ETD 34/17/11,13.21 ETD 39/20/13,19.92 ETD 44/22/15,29.96 ETD 49/25/16,40.34 PQ 20/20,5.80 PQ 26/20,10.15 PQ 26/25,12.47 PQ 32/20,14.43 PQ 32/30,21.37 \end{filecontents} \pgfplotstableread[col sep=comma]{datensuperfein.dat}\datatable \makeatletter \pgfplotsset{ /pgfplots/flexible xticklabels from table/.code n args={3}{% \pgfplotstableread[#3]{#1}\coordinate@table \pgfplotstablegetcolumn{#2}\of{\coordinate@table}\to\pgfplots@xticklabels \let\pgfplots@xticklabel=\pgfplots@user@ticklabel@list@x } } \begin{document} \begin{figure} \centering \begin{tikzpicture} \begin{axis}[ ybar, ymin=0, xlabel=Xstuff, ylabel=Value, flexible xticklabels from table={datensuperfein.dat}{x}{col sep=comma}, xticklabel style={text height=1.5ex}, % To make sure the text labels are nicely aligned xtick=data, nodes near coords, nodes near coords align={vertical}] \addplot table[x expr=\coordindex,y=y]{\datatable}; \end{axis} \end{tikzpicture} \caption{Caption} \end{figure} \end{document}