<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to 230: bug when trying to store `\pgfplotstablegetrowsof` with `\pgfmathsetmacro` </title><link>https://sourceforge.net/p/pgfplots/bugs/230/</link><description>Recent changes to 230: bug when trying to store `\pgfplotstablegetrowsof` with `\pgfmathsetmacro` </description><atom:link href="https://sourceforge.net/p/pgfplots/bugs/230/feed.rss" rel="self"/><language>en</language><lastBuildDate>Sat, 30 Nov 2019 20:29:42 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/pgfplots/bugs/230/feed.rss" rel="self" type="application/rss+xml"/><item><title>#230 bug when trying to store `\pgfplotstablegetrowsof` with `\pgfmathsetmacro` </title><link>https://sourceforge.net/p/pgfplots/bugs/230/?limit=100#bd90</link><description>&lt;div class="markdown_content"&gt;&lt;ul&gt;
&lt;li&gt;Description has changed:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Diff:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gd"&gt;--- old&lt;/span&gt;
&lt;span class="gi"&gt;+++ new&lt;/span&gt;
&lt;span class="gu"&gt;@@ -19,74 +19,76 @@&lt;/span&gt;

 MWE:

&lt;span class="gd"&gt;-    % used PGFPlots v1.16&lt;/span&gt;
&lt;span class="gd"&gt;-        % first put the data to an external file or a table,&lt;/span&gt;
&lt;span class="gd"&gt;-        % so it can be handled by the `pgfplotstable&amp;amp;#39; package&lt;/span&gt;
&lt;span class="gd"&gt;-        \begin{filecontents}{data.txt}&lt;/span&gt;
&lt;span class="gd"&gt;-            0   0&lt;/span&gt;
&lt;span class="gd"&gt;-            1   1&lt;/span&gt;
&lt;span class="gd"&gt;-            2   2&lt;/span&gt;
&lt;span class="gd"&gt;-            3   3&lt;/span&gt;
&lt;span class="gd"&gt;-            4   4&lt;/span&gt;
&lt;span class="gd"&gt;-        \end{filecontents}&lt;/span&gt;
&lt;span class="gd"&gt;-    \documentclass[border=5pt]{standalone}&lt;/span&gt;
&lt;span class="gd"&gt;-    \usepackage{pgfplots}&lt;/span&gt;
&lt;span class="gd"&gt;-    \usepackage{pgfplotstable}&lt;/span&gt;
&lt;span class="gd"&gt;-        \usetikzlibrary{&lt;/span&gt;
&lt;span class="gd"&gt;-            fpu,&lt;/span&gt;
&lt;span class="gd"&gt;-            positioning,    % &amp;amp;lt;-- for debugging nodes only&lt;/span&gt;
&lt;span class="gi"&gt;+~~~latex&lt;/span&gt;
&lt;span class="gi"&gt;+% used PGFPlots v1.16&lt;/span&gt;
&lt;span class="gi"&gt;+    % first put the data to an external file or a table,&lt;/span&gt;
&lt;span class="gi"&gt;+    % so it can be handled by the `pgfplotstable&amp;amp;#39; package&lt;/span&gt;
&lt;span class="gi"&gt;+    \begin{filecontents}{data.txt}&lt;/span&gt;
&lt;span class="gi"&gt;+        0   0&lt;/span&gt;
&lt;span class="gi"&gt;+        1   1&lt;/span&gt;
&lt;span class="gi"&gt;+        2   2&lt;/span&gt;
&lt;span class="gi"&gt;+        3   3&lt;/span&gt;
&lt;span class="gi"&gt;+        4   4&lt;/span&gt;
&lt;span class="gi"&gt;+    \end{filecontents}&lt;/span&gt;
&lt;span class="gi"&gt;+\documentclass[border=5pt]{standalone}&lt;/span&gt;
&lt;span class="gi"&gt;+\usepackage{pgfplots}&lt;/span&gt;
&lt;span class="gi"&gt;+\usepackage{pgfplotstable}&lt;/span&gt;
&lt;span class="gi"&gt;+    \usetikzlibrary{&lt;/span&gt;
&lt;span class="gi"&gt;+        fpu,&lt;/span&gt;
&lt;span class="gi"&gt;+        positioning,    % &amp;amp;lt;-- for debugging nodes only&lt;/span&gt;
&lt;span class="gi"&gt;+    }&lt;/span&gt;
&lt;span class="gi"&gt;+    \pgfplotsset{&lt;/span&gt;
&lt;span class="gi"&gt;+        compat=1.16,&lt;/span&gt;
&lt;span class="gi"&gt;+    }&lt;/span&gt;
&lt;span class="gi"&gt;+\begin{document}&lt;/span&gt;
&lt;span class="gi"&gt;+    \begin{tikzpicture}&lt;/span&gt;
&lt;span class="gi"&gt;+        % to be sure that no numbers are interpreted as zero, activate `fpu&amp;amp;#39;&lt;/span&gt;
&lt;span class="gi"&gt;+        % library&lt;/span&gt;
&lt;span class="gi"&gt;+        \tikzset{&lt;/span&gt;
&lt;span class="gi"&gt;+            fpu=true,&lt;/span&gt;
         }
&lt;span class="gd"&gt;-        \pgfplotsset{&lt;/span&gt;
&lt;span class="gd"&gt;-            compat=1.16,&lt;/span&gt;
&lt;span class="gi"&gt;+            %%% find `xmin&amp;amp;#39; and `xmax&amp;amp;#39;&lt;/span&gt;
&lt;span class="gi"&gt;+            % for that first sort the table after the x values&lt;/span&gt;
&lt;span class="gi"&gt;+            \pgfplotstablesort{\SortedTable}{data.txt}&lt;/span&gt;
&lt;span class="gi"&gt;+            % then one can directly extract `xmin&amp;amp;#39;&lt;/span&gt;
&lt;span class="gi"&gt;+            \pgfplotstablegetelem{0}{[index] 0}\of\SortedTable&lt;/span&gt;
&lt;span class="gi"&gt;+                \pgfmathsetmacro{\xmin}{\pgfplotsretval}&lt;/span&gt;
&lt;span class="gi"&gt;+            %% now extract `xmax&amp;amp;#39;&lt;/span&gt;
&lt;span class="gi"&gt;+            % for that we first need to extract the number of rows in the table&lt;/span&gt;
&lt;span class="gi"&gt;+            \pgfplotstablegetrowsof{\SortedTable}&lt;/span&gt;
&lt;span class="gi"&gt;+                \pgfmathsetmacro{\NoOfRows}{\pgfplotsretval-1}&lt;/span&gt;
&lt;span class="gi"&gt;+            % then we can extract the last entry in the sorted table&lt;/span&gt;
&lt;span class="gi"&gt;+            % (I think because of a bug this doesn&amp;amp;#39;t work so one has to&lt;/span&gt;
&lt;span class="gi"&gt;+            %  enter the index manually)&lt;/span&gt;
&lt;span class="gi"&gt;+            \pgfplotstablegetelem{\NoOfRows}{[index] 0}\of\SortedTable&lt;/span&gt;
&lt;span class="gi"&gt;+%            \pgfplotstablegetelem{4}{[index] 0}\of\SortedTable&lt;/span&gt;
&lt;span class="gi"&gt;+                \pgfmathsetmacro{\xmax}{\pgfplotsretval}&lt;/span&gt;
&lt;span class="gi"&gt;+&lt;/span&gt;
&lt;span class="gi"&gt;+        \tikzset{&lt;/span&gt;
&lt;span class="gi"&gt;+            fpu=false,&lt;/span&gt;
         }
&lt;span class="gd"&gt;-    \begin{document}&lt;/span&gt;
&lt;span class="gd"&gt;-        \begin{tikzpicture}&lt;/span&gt;
&lt;span class="gd"&gt;-            % to be sure that no numbers are interpreted as zero, activate `fpu&amp;amp;#39;&lt;/span&gt;
&lt;span class="gd"&gt;-            % library&lt;/span&gt;
&lt;span class="gd"&gt;-            \tikzset{&lt;/span&gt;
&lt;span class="gd"&gt;-                fpu=true,&lt;/span&gt;
&lt;span class="gd"&gt;-            }&lt;/span&gt;
&lt;span class="gd"&gt;-                %%% find `xmin&amp;amp;#39; and `xmax&amp;amp;#39;&lt;/span&gt;
&lt;span class="gd"&gt;-                % for that first sort the table after the x values&lt;/span&gt;
&lt;span class="gd"&gt;-                \pgfplotstablesort{\SortedTable}{data.txt}&lt;/span&gt;
&lt;span class="gd"&gt;-                % then one can directly extract `xmin&amp;amp;#39;&lt;/span&gt;
&lt;span class="gd"&gt;-                \pgfplotstablegetelem{0}{[index] 0}\of\SortedTable&lt;/span&gt;
&lt;span class="gd"&gt;-                    \pgfmathsetmacro{\xmin}{\pgfplotsretval}&lt;/span&gt;
&lt;span class="gd"&gt;-                %% now extract `xmax&amp;amp;#39;&lt;/span&gt;
&lt;span class="gd"&gt;-                % for that we first need to extract the number of rows in the table&lt;/span&gt;
&lt;span class="gd"&gt;-                \pgfplotstablegetrowsof{\SortedTable}&lt;/span&gt;
&lt;span class="gd"&gt;-                    \pgfmathsetmacro{\NoOfRows}{\pgfplotsretval-1}&lt;/span&gt;
&lt;span class="gd"&gt;-                % then we can extract the last entry in the sorted table&lt;/span&gt;
&lt;span class="gd"&gt;-                % (I think because of a bug this doesn&amp;amp;#39;t work so one has to&lt;/span&gt;
&lt;span class="gd"&gt;-                %  enter the index manually)&lt;/span&gt;
&lt;span class="gd"&gt;-                \pgfplotstablegetelem{\NoOfRows}{[index] 0}\of\SortedTable&lt;/span&gt;
&lt;span class="gd"&gt;-    %            \pgfplotstablegetelem{4}{[index] 0}\of\SortedTable&lt;/span&gt;
&lt;span class="gd"&gt;-                    \pgfmathsetmacro{\xmax}{\pgfplotsretval}&lt;/span&gt;

&lt;span class="gd"&gt;-            \tikzset{&lt;/span&gt;
&lt;span class="gd"&gt;-                fpu=false,&lt;/span&gt;
&lt;span class="gd"&gt;-            }&lt;/span&gt;
&lt;span class="gi"&gt;+        \begin{axis}[&lt;/span&gt;
&lt;span class="gi"&gt;+            % add the extra ticks from the extracted data&lt;/span&gt;
&lt;span class="gi"&gt;+            extra x ticks={&lt;/span&gt;
&lt;span class="gi"&gt;+                \xmin,&lt;/span&gt;
&lt;span class="gi"&gt;+                \xmax&lt;/span&gt;
&lt;span class="gi"&gt;+            },&lt;/span&gt;
&lt;span class="gi"&gt;+            % just to make sure these are the extra ticks, draw them red&lt;/span&gt;
&lt;span class="gi"&gt;+            extra x tick style={&lt;/span&gt;
&lt;span class="gi"&gt;+                text=red,&lt;/span&gt;
&lt;span class="gi"&gt;+            },&lt;/span&gt;
&lt;span class="gi"&gt;+        ]&lt;/span&gt;
&lt;span class="gi"&gt;+            \addplot +[black, mark options=fill=black] table {data.txt};&lt;/span&gt;

&lt;span class="gd"&gt;-            \begin{axis}[&lt;/span&gt;
&lt;span class="gd"&gt;-                % add the extra ticks from the extracted data&lt;/span&gt;
&lt;span class="gd"&gt;-                extra x ticks={&lt;/span&gt;
&lt;span class="gd"&gt;-                    \xmin,&lt;/span&gt;
&lt;span class="gd"&gt;-                    \xmax&lt;/span&gt;
&lt;span class="gd"&gt;-                },&lt;/span&gt;
&lt;span class="gd"&gt;-                % just to make sure these are the extra ticks, draw them red&lt;/span&gt;
&lt;span class="gd"&gt;-                extra x tick style={&lt;/span&gt;
&lt;span class="gd"&gt;-                    text=red,&lt;/span&gt;
&lt;span class="gd"&gt;-                },&lt;/span&gt;
&lt;span class="gd"&gt;-            ]&lt;/span&gt;
&lt;span class="gd"&gt;-                \addplot +[black, mark options=fill=black] table {data.txt};&lt;/span&gt;
&lt;span class="gd"&gt;-&lt;/span&gt;
&lt;span class="gd"&gt;-                % for debugging show the value of `xmax&amp;amp;#39;&lt;/span&gt;
&lt;span class="gd"&gt;-                \node [fill=black!25,anchor=north west]  (a) at (rel axis cs:0.02,0.98)&lt;/span&gt;
&lt;span class="gd"&gt;-                    {Rows = \pgfmathprintnumber{\NoOfRows}};&lt;/span&gt;
&lt;span class="gd"&gt;-                \node [fill=black!25,below=1pt of a.south west,anchor=north west]&lt;/span&gt;
&lt;span class="gd"&gt;-                    {xmax = \pgfmathprintnumber{\xmax}};&lt;/span&gt;
&lt;span class="gd"&gt;-            \end{axis}&lt;/span&gt;
&lt;span class="gd"&gt;-        \end{tikzpicture}&lt;/span&gt;
&lt;span class="gd"&gt;-    \end{document}&lt;/span&gt;
&lt;span class="gi"&gt;+            % for debugging show the value of `xmax&amp;amp;#39;&lt;/span&gt;
&lt;span class="gi"&gt;+            \node [fill=black!25,anchor=north west]  (a) at (rel axis cs:0.02,0.98)&lt;/span&gt;
&lt;span class="gi"&gt;+                {Rows = \pgfmathprintnumber{\NoOfRows}};&lt;/span&gt;
&lt;span class="gi"&gt;+            \node [fill=black!25,below=1pt of a.south west,anchor=north west]&lt;/span&gt;
&lt;span class="gi"&gt;+                {xmax = \pgfmathprintnumber{\xmax}};&lt;/span&gt;
&lt;span class="gi"&gt;+        \end{axis}&lt;/span&gt;
&lt;span class="gi"&gt;+    \end{tikzpicture}&lt;/span&gt;
&lt;span class="gi"&gt;+\end{document}&lt;/span&gt;
&lt;span class="gi"&gt;+~~~&lt;/span&gt;

 which results in the attached picture.
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stefan Pinnow</dc:creator><pubDate>Sat, 30 Nov 2019 20:29:42 -0000</pubDate><guid>https://sourceforge.net87b4b08c7ed0d5cffb79f66517e93be5782c55ae</guid></item><item><title>bug when trying to store `\pgfplotstablegetrowsof` with `\pgfmathsetmacro` </title><link>https://sourceforge.net/p/pgfplots/bugs/230/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Actually this is a bug that originally was reported in the TikZ/pgf tracker (https://sourceforge.net/p/pgf/bugs/383/, &lt;a href="https://github.com/pgf-tikz/pgf/issues/382" rel="nofollow"&gt;https://github.com/pgf-tikz/pgf/issues/382&lt;/a&gt;) but should most likely have been reported here. So I am "repeating" it here with some minor modifications/updates. I also provide an MWE at the end.&lt;/p&gt;
&lt;hr/&gt;
&lt;p&gt;For simplicity here I only copy some lines of emails in German which should act as a reminder for Christian.&lt;/p&gt;
&lt;p&gt;My email:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;[...]&lt;/span&gt; könntest du mal einen kurzen Blick auf&lt;br/&gt;
&lt;a href="https://tex.stackexchange.com/revisions/299200/3" rel="nofollow"&gt;https://tex.stackexchange.com/revisions/299200/3&lt;/a&gt;&lt;br/&gt;
werfen und mir sagen, ob es ein Bug ist, dass ich &lt;code&gt;\NoOfRows&lt;/code&gt; nicht in &lt;code&gt;\pgfplotstablegetelem&lt;/code&gt; verwenden kann. &lt;span&gt;[...]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;His answer:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;[...]&lt;/span&gt; das mit &lt;code&gt;\NoOfRows&lt;/code&gt; ist eine Mischung aus der komplizierten Nutzung der FPU engine und einem fehlenden sanity check (=bug).&lt;/p&gt;
&lt;p&gt;Was passiert ist dass &lt;code&gt;\NoOfRows&lt;/code&gt; auf &lt;code&gt;1Y4.0e0&lt;/code&gt; gesetzt wird, was soviel heisst wie "+ 4.0 * 10^0". Als Zeilennummer interpretiert scheint der aber nur die "1" genommen zu haben und den Rest stillschweigend weggeworfen zu haben. &lt;span&gt;[...]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;MWE:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;% &lt;span class="n"&gt;used&lt;/span&gt; &lt;span class="n"&gt;PGFPlots&lt;/span&gt; &lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="mf"&gt;.16&lt;/span&gt;
    % &lt;span class="nb"&gt;first&lt;/span&gt; &lt;span class="n"&gt;put&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="nb"&gt;to&lt;/span&gt; &lt;span class="n"&gt;an&lt;/span&gt; &lt;span class="n"&gt;external&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt; &lt;span class="o"&gt;or&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt;,
    % &lt;span class="o"&gt;so&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="nb"&gt;can&lt;/span&gt; &lt;span class="n"&gt;be&lt;/span&gt; &lt;span class="n"&gt;handled&lt;/span&gt; &lt;span class="nb"&gt;by&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; `&lt;span class="n"&gt;pgfplotstable'&lt;/span&gt; &lt;span class="k"&gt;package&lt;/span&gt;
    \&lt;span class="n"&gt;begin&lt;/span&gt;{&lt;span class="n"&gt;filecontents&lt;/span&gt;}{&lt;span class="n"&gt;data&lt;/span&gt;.&lt;span class="n"&gt;txt&lt;/span&gt;}
        &lt;span class="mi"&gt;0&lt;/span&gt;   &lt;span class="mi"&gt;0&lt;/span&gt;
        &lt;span class="mi"&gt;1&lt;/span&gt;   &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="mi"&gt;2&lt;/span&gt;   &lt;span class="mi"&gt;2&lt;/span&gt;
        &lt;span class="mi"&gt;3&lt;/span&gt;   &lt;span class="mi"&gt;3&lt;/span&gt;
        &lt;span class="mi"&gt;4&lt;/span&gt;   &lt;span class="mi"&gt;4&lt;/span&gt;
    \&lt;span class="nb"&gt;end&lt;/span&gt;{&lt;span class="n"&gt;filecontents&lt;/span&gt;}
\&lt;span class="n"&gt;documentclass&lt;/span&gt;[&lt;span class="n"&gt;border&lt;/span&gt;=&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="n"&gt;pt&lt;/span&gt;]{&lt;span class="n"&gt;standalone&lt;/span&gt;}
\&lt;span class="n"&gt;usepackage&lt;/span&gt;{&lt;span class="n"&gt;pgfplots&lt;/span&gt;}
\&lt;span class="n"&gt;usepackage&lt;/span&gt;{&lt;span class="n"&gt;pgfplotstable&lt;/span&gt;}
    \&lt;span class="n"&gt;usetikzlibrary&lt;/span&gt;{
        &lt;span class="n"&gt;fpu&lt;/span&gt;,
        &lt;span class="n"&gt;positioning&lt;/span&gt;,    % &amp;lt;-- &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;debugging&lt;/span&gt; &lt;span class="n"&gt;nodes&lt;/span&gt; &lt;span class="k"&gt;only&lt;/span&gt;
    }
    \&lt;span class="n"&gt;pgfplotsset&lt;/span&gt;{
        &lt;span class="n"&gt;compat&lt;/span&gt;=&lt;span class="mf"&gt;1.16&lt;/span&gt;,
    }
\&lt;span class="n"&gt;begin&lt;/span&gt;{&lt;span class="n"&gt;document&lt;/span&gt;}
    \&lt;span class="n"&gt;begin&lt;/span&gt;{&lt;span class="n"&gt;tikzpicture&lt;/span&gt;}
        % &lt;span class="nb"&gt;to&lt;/span&gt; &lt;span class="n"&gt;be&lt;/span&gt; &lt;span class="n"&gt;sure&lt;/span&gt; &lt;span class="n"&gt;that&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="n"&gt;are&lt;/span&gt; &lt;span class="n"&gt;interpreted&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;zero&lt;/span&gt;, &lt;span class="n"&gt;activate&lt;/span&gt; `&lt;span class="n"&gt;fpu'&lt;/span&gt;
        % &lt;span class="n"&gt;library&lt;/span&gt;
        \&lt;span class="n"&gt;tikzset&lt;/span&gt;{
            &lt;span class="n"&gt;fpu&lt;/span&gt;=&lt;span class="nb"&gt;true&lt;/span&gt;,
        }
            %%% &lt;span class="n"&gt;find&lt;/span&gt; `&lt;span class="n"&gt;xmin'&lt;/span&gt; &lt;span class="o"&gt;and&lt;/span&gt; `&lt;span class="n"&gt;xmax'&lt;/span&gt;
            % &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;that&lt;/span&gt; &lt;span class="nb"&gt;first&lt;/span&gt; &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt; &lt;span class="o"&gt;after&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="o"&gt;x&lt;/span&gt; &lt;span class="nb"&gt;values&lt;/span&gt;
            \&lt;span class="n"&gt;pgfplotstablesort&lt;/span&gt;{\&lt;span class="n"&gt;SortedTable&lt;/span&gt;}{&lt;span class="n"&gt;data&lt;/span&gt;.&lt;span class="n"&gt;txt&lt;/span&gt;}
            % &lt;span class="n"&gt;then&lt;/span&gt; &lt;span class="nb"&gt;one&lt;/span&gt; &lt;span class="nb"&gt;can&lt;/span&gt; &lt;span class="n"&gt;directly&lt;/span&gt; &lt;span class="n"&gt;extract&lt;/span&gt; `&lt;span class="n"&gt;xmin'&lt;/span&gt;
            \&lt;span class="n"&gt;pgfplotstablegetelem&lt;/span&gt;{&lt;span class="mi"&gt;0&lt;/span&gt;}{[&lt;span class="nb"&gt;index&lt;/span&gt;] &lt;span class="mi"&gt;0&lt;/span&gt;}\&lt;span class="k"&gt;of&lt;/span&gt;\&lt;span class="n"&gt;SortedTable&lt;/span&gt;
                \&lt;span class="n"&gt;pgfmathsetmacro&lt;/span&gt;{\&lt;span class="n"&gt;xmin&lt;/span&gt;}{\&lt;span class="n"&gt;pgfplotsretval&lt;/span&gt;}
            %% &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="n"&gt;extract&lt;/span&gt; `&lt;span class="n"&gt;xmax'&lt;/span&gt;
            % &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;that&lt;/span&gt; &lt;span class="n"&gt;we&lt;/span&gt; &lt;span class="nb"&gt;first&lt;/span&gt; &lt;span class="n"&gt;need&lt;/span&gt; &lt;span class="nb"&gt;to&lt;/span&gt; &lt;span class="n"&gt;extract&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt;
            \&lt;span class="n"&gt;pgfplotstablegetrowsof&lt;/span&gt;{\&lt;span class="n"&gt;SortedTable&lt;/span&gt;}
                \&lt;span class="n"&gt;pgfmathsetmacro&lt;/span&gt;{\&lt;span class="n"&gt;NoOfRows&lt;/span&gt;}{\&lt;span class="n"&gt;pgfplotsretval-1&lt;/span&gt;}
            % &lt;span class="n"&gt;then&lt;/span&gt; &lt;span class="n"&gt;we&lt;/span&gt; &lt;span class="nb"&gt;can&lt;/span&gt; &lt;span class="n"&gt;extract&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="k"&gt;last&lt;/span&gt; &lt;span class="n"&gt;entry&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;sorted&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt;
            % (&lt;span class="n"&gt;I&lt;/span&gt; &lt;span class="n"&gt;think&lt;/span&gt; &lt;span class="n"&gt;because&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;bug&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;doesn't&lt;/span&gt; &lt;span class="n"&gt;work&lt;/span&gt; &lt;span class="o"&gt;so&lt;/span&gt; &lt;span class="nb"&gt;one&lt;/span&gt; &lt;span class="k"&gt;has&lt;/span&gt; &lt;span class="nb"&gt;to&lt;/span&gt;
            %  &lt;span class="n"&gt;enter&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="nb"&gt;index&lt;/span&gt; &lt;span class="n"&gt;manually&lt;/span&gt;)
            \&lt;span class="n"&gt;pgfplotstablegetelem&lt;/span&gt;{\&lt;span class="n"&gt;NoOfRows&lt;/span&gt;}{[&lt;span class="nb"&gt;index&lt;/span&gt;] &lt;span class="mi"&gt;0&lt;/span&gt;}\&lt;span class="k"&gt;of&lt;/span&gt;\&lt;span class="n"&gt;SortedTable&lt;/span&gt;
%            \&lt;span class="n"&gt;pgfplotstablegetelem&lt;/span&gt;{&lt;span class="mi"&gt;4&lt;/span&gt;}{[&lt;span class="nb"&gt;index&lt;/span&gt;] &lt;span class="mi"&gt;0&lt;/span&gt;}\&lt;span class="k"&gt;of&lt;/span&gt;\&lt;span class="n"&gt;SortedTable&lt;/span&gt;
                \&lt;span class="n"&gt;pgfmathsetmacro&lt;/span&gt;{\&lt;span class="n"&gt;xmax&lt;/span&gt;}{\&lt;span class="n"&gt;pgfplotsretval&lt;/span&gt;}

        \&lt;span class="n"&gt;tikzset&lt;/span&gt;{
            &lt;span class="n"&gt;fpu&lt;/span&gt;=&lt;span class="n"&gt;false&lt;/span&gt;,
        }

        \&lt;span class="n"&gt;begin&lt;/span&gt;{&lt;span class="n"&gt;axis&lt;/span&gt;}[
            % &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="o"&gt;extra&lt;/span&gt; &lt;span class="n"&gt;ticks&lt;/span&gt; &lt;span class="nb"&gt;from&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;extracted&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;
            &lt;span class="o"&gt;extra&lt;/span&gt; &lt;span class="o"&gt;x&lt;/span&gt; &lt;span class="n"&gt;ticks&lt;/span&gt;={
                \&lt;span class="n"&gt;xmin&lt;/span&gt;,
                \&lt;span class="n"&gt;xmax&lt;/span&gt;
            },
            % &lt;span class="n"&gt;just&lt;/span&gt; &lt;span class="nb"&gt;to&lt;/span&gt; &lt;span class="k"&gt;make&lt;/span&gt; &lt;span class="n"&gt;sure&lt;/span&gt; &lt;span class="n"&gt;these&lt;/span&gt; &lt;span class="n"&gt;are&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="o"&gt;extra&lt;/span&gt; &lt;span class="n"&gt;ticks&lt;/span&gt;, &lt;span class="n"&gt;draw&lt;/span&gt; &lt;span class="n"&gt;them&lt;/span&gt; &lt;span class="n"&gt;red&lt;/span&gt;
            &lt;span class="o"&gt;extra&lt;/span&gt; &lt;span class="o"&gt;x&lt;/span&gt; &lt;span class="n"&gt;tick&lt;/span&gt; &lt;span class="n"&gt;style&lt;/span&gt;={
                &lt;span class="n"&gt;text&lt;/span&gt;=&lt;span class="n"&gt;red&lt;/span&gt;,
            },
        ]
            \&lt;span class="n"&gt;addplot&lt;/span&gt; +[&lt;span class="n"&gt;black&lt;/span&gt;, &lt;span class="n"&gt;mark&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;=&lt;span class="n"&gt;fill&lt;/span&gt;=&lt;span class="n"&gt;black&lt;/span&gt;] &lt;span class="n"&gt;table&lt;/span&gt; {&lt;span class="n"&gt;data&lt;/span&gt;.&lt;span class="n"&gt;txt&lt;/span&gt;};

            % &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;debugging&lt;/span&gt; &lt;span class="n"&gt;show&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="nb"&gt;value&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; `&lt;span class="n"&gt;xmax'&lt;/span&gt;
            \&lt;span class="n"&gt;node&lt;/span&gt; [&lt;span class="n"&gt;fill&lt;/span&gt;=&lt;span class="n"&gt;black&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;,&lt;span class="n"&gt;anchor&lt;/span&gt;=&lt;span class="n"&gt;north&lt;/span&gt; &lt;span class="n"&gt;west&lt;/span&gt;]  (&lt;span class="n"&gt;a&lt;/span&gt;) &lt;span class="n"&gt;at&lt;/span&gt; (&lt;span class="n"&gt;rel&lt;/span&gt; &lt;span class="n"&gt;axis&lt;/span&gt; &lt;span class="n"&gt;cs:0&lt;/span&gt;&lt;span class="mf"&gt;.02&lt;/span&gt;,&lt;span class="mf"&gt;0.98&lt;/span&gt;)
                {&lt;span class="n"&gt;Rows&lt;/span&gt; = \&lt;span class="n"&gt;pgfmathprintnumber&lt;/span&gt;{\&lt;span class="n"&gt;NoOfRows&lt;/span&gt;}};
            \&lt;span class="n"&gt;node&lt;/span&gt; [&lt;span class="n"&gt;fill&lt;/span&gt;=&lt;span class="n"&gt;black&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;,&lt;span class="n"&gt;below&lt;/span&gt;=&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="n"&gt;pt&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;.&lt;span class="n"&gt;south&lt;/span&gt; &lt;span class="n"&gt;west&lt;/span&gt;,&lt;span class="n"&gt;anchor&lt;/span&gt;=&lt;span class="n"&gt;north&lt;/span&gt; &lt;span class="n"&gt;west&lt;/span&gt;]
                {&lt;span class="n"&gt;xmax&lt;/span&gt; = \&lt;span class="n"&gt;pgfmathprintnumber&lt;/span&gt;{\&lt;span class="n"&gt;xmax&lt;/span&gt;}};
        \&lt;span class="nb"&gt;end&lt;/span&gt;{&lt;span class="n"&gt;axis&lt;/span&gt;}
    \&lt;span class="nb"&gt;end&lt;/span&gt;{&lt;span class="n"&gt;tikzpicture&lt;/span&gt;}
\&lt;span class="nb"&gt;end&lt;/span&gt;{&lt;span class="n"&gt;document&lt;/span&gt;}
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;which results in the attached picture.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stefan Pinnow</dc:creator><pubDate>Sat, 30 Nov 2019 20:28:07 -0000</pubDate><guid>https://sourceforge.net5c1d9120fb5bd0d242159420b5ac987f6438503a</guid></item><item><title>bug when trying to store `\pgfplotstablegetrowsof` with `\pgfmathsetmacro` </title><link>https://sourceforge.net/p/pgfplots/bugs/230/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Ticket 230 has been modified: bug when trying to store &lt;code&gt;\pgfplotstablegetrowsof&lt;/code&gt; with &lt;code&gt;\pgfmathsetmacro&lt;/code&gt; &lt;br/&gt;
Edited By: Stefan Pinnow (mo-gul)&lt;br/&gt;
Description updated:&lt;br/&gt;
--- description-old&lt;/p&gt;
&lt;p&gt;+++ description-new&lt;/p&gt;
&lt;p&gt;@@ -19,74 +19,76 @@&lt;/p&gt;
&lt;p&gt;MWE:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;% used PGFPlots v1.16&lt;/li&gt;
&lt;li&gt;% first put the data to an external file or a table,&lt;/li&gt;
&lt;li&gt;% so it can be handled by the `pgfplotstable' package&lt;/li&gt;
&lt;li&gt;\begin{filecontents}{data.txt}&lt;/li&gt;
&lt;li&gt;0   0&lt;/li&gt;
&lt;li&gt;1   1&lt;/li&gt;
&lt;li&gt;2   2&lt;/li&gt;
&lt;li&gt;3   3&lt;/li&gt;
&lt;li&gt;4   4&lt;/li&gt;
&lt;li&gt;\end{filecontents}&lt;/li&gt;
&lt;li&gt;\documentclass&lt;span&gt;[border=5pt]&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;\usepackage{pgfplots}&lt;/li&gt;
&lt;li&gt;\usepackage{pgfplotstable}&lt;/li&gt;
&lt;li&gt;\usetikzlibrary{&lt;/li&gt;
&lt;li&gt;fpu,&lt;/li&gt;
&lt;li&gt;positioning,    % &amp;lt;-- for debugging nodes only&lt;br/&gt;
+~~~latex&lt;br/&gt;
+% used PGFPlots v1.16&lt;/li&gt;
&lt;li&gt;% first put the data to an external file or a table,&lt;/li&gt;
&lt;li&gt;% so it can be handled by the `pgfplotstable' package&lt;/li&gt;
&lt;li&gt;\begin{filecontents}{data.txt}&lt;/li&gt;
&lt;li&gt;0   0&lt;/li&gt;
&lt;li&gt;1   1&lt;/li&gt;
&lt;li&gt;2   2&lt;/li&gt;
&lt;li&gt;3   3&lt;/li&gt;
&lt;li&gt;4   4&lt;/li&gt;
&lt;li&gt;\end{filecontents}&lt;br/&gt;
+\documentclass&lt;span&gt;[border=5pt]&lt;/span&gt;&lt;br/&gt;
+\usepackage{pgfplots}&lt;br/&gt;
+\usepackage{pgfplotstable}&lt;/li&gt;
&lt;li&gt;\usetikzlibrary{&lt;/li&gt;
&lt;li&gt;fpu,&lt;/li&gt;
&lt;li&gt;positioning,    % &amp;lt;-- for debugging nodes only&lt;/li&gt;
&lt;li&gt;}&lt;/li&gt;
&lt;li&gt;\pgfplotsset{&lt;/li&gt;
&lt;li&gt;compat=1.16,&lt;/li&gt;
&lt;li&gt;}&lt;br/&gt;
+\begin{document}&lt;/li&gt;
&lt;li&gt;\begin{tikzpicture}&lt;/li&gt;
&lt;li&gt;% to be sure that no numbers are interpreted as zero, activate `fpu'&lt;/li&gt;
&lt;li&gt;% library&lt;/li&gt;
&lt;li&gt;\tikzset{&lt;/li&gt;
&lt;li&gt;fpu=true,&lt;br/&gt;
         }&lt;/li&gt;
&lt;li&gt;\pgfplotsset{&lt;/li&gt;
&lt;li&gt;compat=1.16,&lt;/li&gt;
&lt;li&gt;%%% find &lt;code&gt;xmin' and&lt;/code&gt;xmax'&lt;/li&gt;
&lt;li&gt;% for that first sort the table after the x values&lt;/li&gt;
&lt;li&gt;\pgfplotstablesort{\SortedTable}{data.txt}&lt;/li&gt;
&lt;li&gt;% then one can directly extract `xmin'&lt;/li&gt;
&lt;li&gt;\pgfplotstablegetelem{0}{&lt;span&gt;[index]&lt;/span&gt; 0}\of\SortedTable&lt;/li&gt;
&lt;li&gt;\pgfmathsetmacro{\xmin}{\pgfplotsretval}&lt;/li&gt;
&lt;li&gt;%% now extract `xmax'&lt;/li&gt;
&lt;li&gt;% for that we first need to extract the number of rows in the table&lt;/li&gt;
&lt;li&gt;\pgfplotstablegetrowsof{\SortedTable}&lt;/li&gt;
&lt;li&gt;\pgfmathsetmacro{\NoOfRows}{\pgfplotsretval-1}&lt;/li&gt;
&lt;li&gt;% then we can extract the last entry in the sorted table&lt;/li&gt;
&lt;li&gt;% (I think because of a bug this doesn't work so one has to&lt;/li&gt;
&lt;li&gt;%  enter the index manually)&lt;/li&gt;
&lt;li&gt;\pgfplotstablegetelem{\NoOfRows}{&lt;span&gt;[index]&lt;/span&gt; 0}\of\SortedTable&lt;br/&gt;
+%            \pgfplotstablegetelem{4}{&lt;span&gt;[index]&lt;/span&gt; 0}\of\SortedTable&lt;/li&gt;
&lt;li&gt;\pgfmathsetmacro{\xmax}{\pgfplotsretval}&lt;br/&gt;
+&lt;/li&gt;
&lt;li&gt;\tikzset{&lt;/li&gt;
&lt;li&gt;fpu=false,&lt;br/&gt;
         }&lt;/li&gt;
&lt;li&gt;\begin{document}&lt;/li&gt;
&lt;li&gt;\begin{tikzpicture}&lt;/li&gt;
&lt;li&gt;% to be sure that no numbers are interpreted as zero, activate `fpu'&lt;/li&gt;
&lt;li&gt;% library&lt;/li&gt;
&lt;li&gt;\tikzset{&lt;/li&gt;
&lt;li&gt;fpu=true,&lt;/li&gt;
&lt;li&gt;}&lt;/li&gt;
&lt;li&gt;%%% find &lt;code&gt;xmin' and&lt;/code&gt;xmax'&lt;/li&gt;
&lt;li&gt;% for that first sort the table after the x values&lt;/li&gt;
&lt;li&gt;\pgfplotstablesort{\SortedTable}{data.txt}&lt;/li&gt;
&lt;li&gt;% then one can directly extract `xmin'&lt;/li&gt;
&lt;li&gt;\pgfplotstablegetelem{0}{&lt;span&gt;[index]&lt;/span&gt; 0}\of\SortedTable&lt;/li&gt;
&lt;li&gt;\pgfmathsetmacro{\xmin}{\pgfplotsretval}&lt;/li&gt;
&lt;li&gt;%% now extract `xmax'&lt;/li&gt;
&lt;li&gt;% for that we first need to extract the number of rows in the table&lt;/li&gt;
&lt;li&gt;\pgfplotstablegetrowsof{\SortedTable}&lt;/li&gt;
&lt;li&gt;\pgfmathsetmacro{\NoOfRows}{\pgfplotsretval-1}&lt;/li&gt;
&lt;li&gt;% then we can extract the last entry in the sorted table&lt;/li&gt;
&lt;li&gt;% (I think because of a bug this doesn't work so one has to&lt;/li&gt;
&lt;li&gt;%  enter the index manually)&lt;/li&gt;
&lt;li&gt;\pgfplotstablegetelem{\NoOfRows}{&lt;span&gt;[index]&lt;/span&gt; 0}\of\SortedTable&lt;/li&gt;
&lt;li&gt;%            \pgfplotstablegetelem{4}{&lt;span&gt;[index]&lt;/span&gt; 0}\of\SortedTable&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;\pgfmathsetmacro{\xmax}{\pgfplotsretval}&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;\tikzset{&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;fpu=false,&lt;/li&gt;
&lt;li&gt;}&lt;/li&gt;
&lt;li&gt;\begin{axis}[&lt;/li&gt;
&lt;li&gt;% add the extra ticks from the extracted data&lt;/li&gt;
&lt;li&gt;extra x ticks={&lt;/li&gt;
&lt;li&gt;\xmin,&lt;/li&gt;
&lt;li&gt;\xmax&lt;/li&gt;
&lt;li&gt;},&lt;/li&gt;
&lt;li&gt;% just to make sure these are the extra ticks, draw them red&lt;/li&gt;
&lt;li&gt;extra x tick style={&lt;/li&gt;
&lt;li&gt;text=red,&lt;/li&gt;
&lt;li&gt;},&lt;/li&gt;
&lt;li&gt;]&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;\addplot +&lt;span&gt;[black, mark options=fill=black]&lt;/span&gt; table {data.txt};&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;\begin{axis}[&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;% add the extra ticks from the extracted data&lt;/li&gt;
&lt;li&gt;extra x ticks={&lt;/li&gt;
&lt;li&gt;\xmin,&lt;/li&gt;
&lt;li&gt;\xmax&lt;/li&gt;
&lt;li&gt;},&lt;/li&gt;
&lt;li&gt;% just to make sure these are the extra ticks, draw them red&lt;/li&gt;
&lt;li&gt;extra x tick style={&lt;/li&gt;
&lt;li&gt;text=red,&lt;/li&gt;
&lt;li&gt;},&lt;/li&gt;
&lt;li&gt;]&lt;/li&gt;
&lt;li&gt;
&lt;h2 id="addplot-black-mark-optionsfillblack-table-datatxt"&gt;\addplot +&lt;span&gt;[black, mark options=fill=black]&lt;/span&gt; table {data.txt};&lt;/h2&gt;
&lt;/li&gt;
&lt;li&gt;% for debugging show the value of `xmax'&lt;/li&gt;
&lt;li&gt;\node &lt;span&gt;[fill=black!25,anchor=north west]&lt;/span&gt;  (a) at (rel axis cs:0.02,0.98)&lt;/li&gt;
&lt;li&gt;{Rows = \pgfmathprintnumber{\NoOfRows}};&lt;/li&gt;
&lt;li&gt;\node &lt;span&gt;[fill=black!25,below=1pt of a.south west,anchor=north west]&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;{xmax = \pgfmathprintnumber{\xmax}};&lt;/li&gt;
&lt;li&gt;\end{axis}&lt;/li&gt;
&lt;li&gt;\end{tikzpicture}&lt;/li&gt;
&lt;li&gt;\end{document}&lt;/li&gt;
&lt;li&gt;% for debugging show the value of `xmax'&lt;/li&gt;
&lt;li&gt;\node &lt;span&gt;[fill=black!25,anchor=north west]&lt;/span&gt;  (a) at (rel axis cs:0.02,0.98)&lt;/li&gt;
&lt;li&gt;{Rows = \pgfmathprintnumber{\NoOfRows}};&lt;/li&gt;
&lt;li&gt;\node &lt;span&gt;[fill=black!25,below=1pt of a.south west,anchor=north west]&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;{xmax = \pgfmathprintnumber{\xmax}};&lt;/li&gt;
&lt;li&gt;\end{axis}&lt;/li&gt;
&lt;li&gt;\end{tikzpicture}&lt;br/&gt;
+\end{document}&lt;br/&gt;
+~~~&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;which results in the attached picture.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stefan Pinnow</dc:creator><pubDate>Sat, 30 Nov 2019 20:28:07 -0000</pubDate><guid>https://sourceforge.net78f3c0768c408b9d93a2938ed150ae376076dfe5</guid></item></channel></rss>