Ich möchte, die Zellen der ersten Spalte mit jenen der zweiten vergleichen.

So soll z.B. in der allerersten Zelle 1 > 0.5 stehen.

Wie kann ich auf die Wert der zweiten Spalte zugreifen?
\thisrow{NewCol} bzw. \pgfmathparse{##1 > \thisrow{NewCol} ? "$>$ \thisrow{NewCol}" : "$\leq$ \thisrow{NewCol}"}\pgfmathresult kennt er nicht.

Im Beispiel nur für den konstanten Vergleichswert 2 gezeigt:
alt text

Öffne in Overleaf
\documentclass[margin=5mm]{standalone}
\usepackage{pgfplotstable}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.dat}
A
1
2
3
\end{filecontents*}

\begin{document}
\pgfplotstableread{\jobname.dat}\results

\pgfplotstablecreatecol[
expr={2*\thisrow{A}-1.5}
]{NewCol}{\results}

\pgfplotstabletypeset[header=false, 
%columns={A, NewCol},
columns/A/.style={column type=l,  
  %  preproc/expr = {##1},
postproc cell content/.style={
/pgfplots/table/@cell content/.add={}{
\pgfmathparse{##1 > 2? "$>$ 2" : "$\leq$ 2"}\pgfmathresult
},},},
]\results
\end{document}

gefragt 08 Nov '18, 23:15

cis's gravatar image

cis
9.5k75452491
Akzeptiert-Rate: 29%

bearbeitet 08 Nov '18, 23:16


Du könntest doch einfach eine neue Spalte erstellen.

Öffne in Overleaf
\documentclass[margin=5mm]{standalone}
\usepackage{pgfplotstable}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.dat}
  A
  1
  2
  3
\end{filecontents*}

\begin{document}
\pgfplotstableread{\jobname.dat}\results

\pgfplotstablecreatecol[
expr={2*\thisrow{A}-1.5}
]{NewCol}{\results}

\pgfplotstablecreatecol[
create col/assign/.code={%
  \getthisrow{A}\a
  \getthisrow{NewCol}\b
  \def\texta{\noexpand\pgfmathprintnumber{\a}}%
  \def\textb{\noexpand\pgfmathprintnumber{\b}}%
  \pgfmathparse{\a > \b ? "$\texta > \textb$" : "$\texta \leq \textb$"}%
  \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult
}
]{Compare}{\results}

\pgfplotstabletypeset[header=false, 
columns={Compare, NewCol},
columns/Compare/.style={
  column name=A,
  string type
}
]\results
\end{document}

alt text

Permanenter link

beantwortet 18 Feb '19, 06:50

Henri's gravatar image

Henri
15.7k133943
Akzeptiert-Rate: 46%

Deine Antwort
Vorschau umschalten

Folgen dieser Frage

Per E-Mail:

Wenn sie sich anmelden, kommen Sie für alle Updates hier in Frage

Per RSS:

Antworten

Antworten und Kommentare

Markdown-Grundlagen

  • *kursiv* oder _kursiv_
  • **Fett** oder __Fett__
  • Link:[Text](http://url.com/ "Titel")
  • Bild?![alt Text](/path/img.jpg "Titel")
  • nummerierte Liste: 1. Foo 2. Bar
  • zum Hinzufügen ein Zeilenumbruchs fügen Sie einfach zwei Leerzeichen an die Stelle an der die neue Linie sein soll.
  • grundlegende HTML-Tags werden ebenfalls unterstützt

Frage-Themen:

×39

gestellte Frage: 08 Nov '18, 23:15

Frage wurde gesehen: 4,018 Mal

zuletzt geändert: 18 Feb '19, 06:50