How can I filter/select data from a table and plot it?












13















I have a table with data from a file and before anything, I sort the data. Then I would like to filter only the rows that have a specific value. There has been a similar question which almost contains the answer to my question:



Selecting rows to be displayed with pgfplotstable



In addition to that I would like to know how to plot the filtered data.



Here is an example:



documentclass{minimal}
usepackage{pgfplotstable}
usepackage{pgfplots}

begin{document}
pgfplotstableread{
T A B C
20 0 450 43
23 0 400 42
25 0 350 41
30 0 320 40
40 0 300 40
20 10 400 38
23 10 380 37
25 10 350 36
30 10 310 35
40 10 280 34
}data

pgfplotstablesort[sort key={T}]{sorted}{data} %get the data and sort by column 'T'

%select data in column 'T' that complies with a certain value and write the table
pgfplotstabletypeset[row predicate/.code={%
pgfplotstablegetelem{#1}{T}of{sorted}
ifnumpgfplotsretval=20relax
elsepgfplotstableuserowfalsefi}]
{sorted}

begin{tikzpicture}
begin{axis}[
xlabel=A,
ylabel=B]
addplot table[
x=A,
y=B]
{filtered}; %here the filtered data from above needs to be addressed, how to do that?
end{axis}
end{tikzpicture}

end{document}


What I don't know is how to address the filtered data above to plot it. I thought it might work by generating a table named filtered.










share|improve this question





























    13















    I have a table with data from a file and before anything, I sort the data. Then I would like to filter only the rows that have a specific value. There has been a similar question which almost contains the answer to my question:



    Selecting rows to be displayed with pgfplotstable



    In addition to that I would like to know how to plot the filtered data.



    Here is an example:



    documentclass{minimal}
    usepackage{pgfplotstable}
    usepackage{pgfplots}

    begin{document}
    pgfplotstableread{
    T A B C
    20 0 450 43
    23 0 400 42
    25 0 350 41
    30 0 320 40
    40 0 300 40
    20 10 400 38
    23 10 380 37
    25 10 350 36
    30 10 310 35
    40 10 280 34
    }data

    pgfplotstablesort[sort key={T}]{sorted}{data} %get the data and sort by column 'T'

    %select data in column 'T' that complies with a certain value and write the table
    pgfplotstabletypeset[row predicate/.code={%
    pgfplotstablegetelem{#1}{T}of{sorted}
    ifnumpgfplotsretval=20relax
    elsepgfplotstableuserowfalsefi}]
    {sorted}

    begin{tikzpicture}
    begin{axis}[
    xlabel=A,
    ylabel=B]
    addplot table[
    x=A,
    y=B]
    {filtered}; %here the filtered data from above needs to be addressed, how to do that?
    end{axis}
    end{tikzpicture}

    end{document}


    What I don't know is how to address the filtered data above to plot it. I thought it might work by generating a table named filtered.










    share|improve this question



























      13












      13








      13


      6






      I have a table with data from a file and before anything, I sort the data. Then I would like to filter only the rows that have a specific value. There has been a similar question which almost contains the answer to my question:



      Selecting rows to be displayed with pgfplotstable



      In addition to that I would like to know how to plot the filtered data.



      Here is an example:



      documentclass{minimal}
      usepackage{pgfplotstable}
      usepackage{pgfplots}

      begin{document}
      pgfplotstableread{
      T A B C
      20 0 450 43
      23 0 400 42
      25 0 350 41
      30 0 320 40
      40 0 300 40
      20 10 400 38
      23 10 380 37
      25 10 350 36
      30 10 310 35
      40 10 280 34
      }data

      pgfplotstablesort[sort key={T}]{sorted}{data} %get the data and sort by column 'T'

      %select data in column 'T' that complies with a certain value and write the table
      pgfplotstabletypeset[row predicate/.code={%
      pgfplotstablegetelem{#1}{T}of{sorted}
      ifnumpgfplotsretval=20relax
      elsepgfplotstableuserowfalsefi}]
      {sorted}

      begin{tikzpicture}
      begin{axis}[
      xlabel=A,
      ylabel=B]
      addplot table[
      x=A,
      y=B]
      {filtered}; %here the filtered data from above needs to be addressed, how to do that?
      end{axis}
      end{tikzpicture}

      end{document}


      What I don't know is how to address the filtered data above to plot it. I thought it might work by generating a table named filtered.










      share|improve this question
















      I have a table with data from a file and before anything, I sort the data. Then I would like to filter only the rows that have a specific value. There has been a similar question which almost contains the answer to my question:



      Selecting rows to be displayed with pgfplotstable



      In addition to that I would like to know how to plot the filtered data.



      Here is an example:



      documentclass{minimal}
      usepackage{pgfplotstable}
      usepackage{pgfplots}

      begin{document}
      pgfplotstableread{
      T A B C
      20 0 450 43
      23 0 400 42
      25 0 350 41
      30 0 320 40
      40 0 300 40
      20 10 400 38
      23 10 380 37
      25 10 350 36
      30 10 310 35
      40 10 280 34
      }data

      pgfplotstablesort[sort key={T}]{sorted}{data} %get the data and sort by column 'T'

      %select data in column 'T' that complies with a certain value and write the table
      pgfplotstabletypeset[row predicate/.code={%
      pgfplotstablegetelem{#1}{T}of{sorted}
      ifnumpgfplotsretval=20relax
      elsepgfplotstableuserowfalsefi}]
      {sorted}

      begin{tikzpicture}
      begin{axis}[
      xlabel=A,
      ylabel=B]
      addplot table[
      x=A,
      y=B]
      {filtered}; %here the filtered data from above needs to be addressed, how to do that?
      end{axis}
      end{tikzpicture}

      end{document}


      What I don't know is how to address the filtered data above to plot it. I thought it might work by generating a table named filtered.







      pgfplots pgfplotstable






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 17 mins ago









      Henri Menke

      75.3k8164276




      75.3k8164276










      asked Aug 7 '12 at 10:50









      wonderwonder

      12117




      12117






















          1 Answer
          1






          active

          oldest

          votes


















          14














          You can use the x filter/.code={} instructions (thanks to Jake for spotting a mistake)



          documentclass{minimal}
          usepackage{pgfplotstable}
          usepackage{pgfplots}

          begin{document}
          pgfplotstableread{
          T A B C
          20 0 450 43
          23 0 400 42
          25 0 350 41
          30 0 320 40
          40 0 300 40
          20 10 400 38
          23 10 380 37
          25 10 350 36
          30 10 310 35
          40 10 280 34
          }data

          pgfplotstablesort[sort key={T}]{sorted}{data}

          pgfplotstabletypeset[row predicate/.code={%
          pgfplotstablegetelem{#1}{T}of{sorted}
          ifnumpgfplotsretval=20relax
          elsepgfplotstableuserowfalsefi}]
          {sorted}


          begin{tikzpicture}
          begin{axis}[
          xlabel=A,
          ylabel=B,
          x filter/.code={pgfplotstablegetelem{coordindex}{T}of{sorted}
          ifnumpgfplotsretval=20
          else
          defpgfmathresult{}
          fi
          },
          ]
          addplot[only marks] table[x=A,y=B] {sorted};
          end{axis}
          end{tikzpicture}
          end{document}


          enter image description here



          If the entries of the table involves nonintegers then ifnum would complain hence it needs another step.



          documentclass{minimal}
          usepackage{pgfplotstable}
          usepackage{pgfplots}

          begin{document}
          pgfplotstableread{
          T A B C
          0.567641034 0.111435797 0.886143166 0.536835288
          0.919931469 0.702921973 0.285814111 0.796042178
          0.073058973 0.921420655 0.806947507 0.570962079
          0.697073289 0.017461888 0.313614435 0.905702895
          0.536575411 0.814853755 0.152870278 0.556116015
          0.574615343 0.162798271 0.553041948 0.605668041
          0.567641034 0.248224272 0.448683336 0.092672169
          0.117628849 0.115555917 0.193712749 0.561100742
          0.625852254 0.993854404 0.950034992 0.595500664
          0.975451837 0.152198913 0.647432196 0.790471281
          0.692695418 0.099750965 0.122178502 0.141174403
          0.106974613 0.905644903 0.491119067 0.795346
          0.727907584 0.408384001 0.586645737 0.172061294
          }data

          pgfplotstablesort[sort key={T}]{sorted}{data}



          begin{tikzpicture}
          begin{axis}[
          xlabel=A,
          ylabel=B,
          x filter/.code={pgfplotstablegetelem{coordindex}{T}of{sorted}
          pgfmathtruncatemacro{tempva}{abs(pgfplotsretval - 0.567641034) == 0 ? 1: 0}
          ifnumtempva>0%true
          else%false
          defpgfmathresult{}
          fi
          },
          ]
          addplot[only marks] table[x=A,y=B] {sorted};
          end{axis}
          end{tikzpicture}
          end{document}


          which leads to the same output above. I have modified a table entry as it is almost passing the test if lowered slightly. So you should be careful about the numerical precision.






          share|improve this answer


























          • @Jake Thanks you are right, that's probably the way but when I did that 2 more coordinates from T column value leaks in. Any idea why?

            – percusse
            Aug 7 '12 at 13:38











          • I tried both codes and they worked fine. @percusse Maybe you have the addplot twice in the code.

            – wonder
            Aug 7 '12 at 13:46











          • @wonder @Jake Nevermind, I was supplying the [x=A,y=B] options to addplot instead of table. I'll fix it in a sec.

            – percusse
            Aug 7 '12 at 13:49













          • One additional question: The above discussed filtering/plotting seems only to work with integers. What needs to be changed if there are floats the table?

            – wonder
            Aug 9 '12 at 9:18






          • 2





            @wonder Please give us a part of your real data and state what is missing so we can give a full working answer. This progress, as you might imagine, is only incremental and becomes difficult to address all issues at one shot each time we implement another detail.

            – percusse
            Aug 10 '12 at 9:43











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "85"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f66177%2fhow-can-i-filter-select-data-from-a-table-and-plot-it%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          14














          You can use the x filter/.code={} instructions (thanks to Jake for spotting a mistake)



          documentclass{minimal}
          usepackage{pgfplotstable}
          usepackage{pgfplots}

          begin{document}
          pgfplotstableread{
          T A B C
          20 0 450 43
          23 0 400 42
          25 0 350 41
          30 0 320 40
          40 0 300 40
          20 10 400 38
          23 10 380 37
          25 10 350 36
          30 10 310 35
          40 10 280 34
          }data

          pgfplotstablesort[sort key={T}]{sorted}{data}

          pgfplotstabletypeset[row predicate/.code={%
          pgfplotstablegetelem{#1}{T}of{sorted}
          ifnumpgfplotsretval=20relax
          elsepgfplotstableuserowfalsefi}]
          {sorted}


          begin{tikzpicture}
          begin{axis}[
          xlabel=A,
          ylabel=B,
          x filter/.code={pgfplotstablegetelem{coordindex}{T}of{sorted}
          ifnumpgfplotsretval=20
          else
          defpgfmathresult{}
          fi
          },
          ]
          addplot[only marks] table[x=A,y=B] {sorted};
          end{axis}
          end{tikzpicture}
          end{document}


          enter image description here



          If the entries of the table involves nonintegers then ifnum would complain hence it needs another step.



          documentclass{minimal}
          usepackage{pgfplotstable}
          usepackage{pgfplots}

          begin{document}
          pgfplotstableread{
          T A B C
          0.567641034 0.111435797 0.886143166 0.536835288
          0.919931469 0.702921973 0.285814111 0.796042178
          0.073058973 0.921420655 0.806947507 0.570962079
          0.697073289 0.017461888 0.313614435 0.905702895
          0.536575411 0.814853755 0.152870278 0.556116015
          0.574615343 0.162798271 0.553041948 0.605668041
          0.567641034 0.248224272 0.448683336 0.092672169
          0.117628849 0.115555917 0.193712749 0.561100742
          0.625852254 0.993854404 0.950034992 0.595500664
          0.975451837 0.152198913 0.647432196 0.790471281
          0.692695418 0.099750965 0.122178502 0.141174403
          0.106974613 0.905644903 0.491119067 0.795346
          0.727907584 0.408384001 0.586645737 0.172061294
          }data

          pgfplotstablesort[sort key={T}]{sorted}{data}



          begin{tikzpicture}
          begin{axis}[
          xlabel=A,
          ylabel=B,
          x filter/.code={pgfplotstablegetelem{coordindex}{T}of{sorted}
          pgfmathtruncatemacro{tempva}{abs(pgfplotsretval - 0.567641034) == 0 ? 1: 0}
          ifnumtempva>0%true
          else%false
          defpgfmathresult{}
          fi
          },
          ]
          addplot[only marks] table[x=A,y=B] {sorted};
          end{axis}
          end{tikzpicture}
          end{document}


          which leads to the same output above. I have modified a table entry as it is almost passing the test if lowered slightly. So you should be careful about the numerical precision.






          share|improve this answer


























          • @Jake Thanks you are right, that's probably the way but when I did that 2 more coordinates from T column value leaks in. Any idea why?

            – percusse
            Aug 7 '12 at 13:38











          • I tried both codes and they worked fine. @percusse Maybe you have the addplot twice in the code.

            – wonder
            Aug 7 '12 at 13:46











          • @wonder @Jake Nevermind, I was supplying the [x=A,y=B] options to addplot instead of table. I'll fix it in a sec.

            – percusse
            Aug 7 '12 at 13:49













          • One additional question: The above discussed filtering/plotting seems only to work with integers. What needs to be changed if there are floats the table?

            – wonder
            Aug 9 '12 at 9:18






          • 2





            @wonder Please give us a part of your real data and state what is missing so we can give a full working answer. This progress, as you might imagine, is only incremental and becomes difficult to address all issues at one shot each time we implement another detail.

            – percusse
            Aug 10 '12 at 9:43
















          14














          You can use the x filter/.code={} instructions (thanks to Jake for spotting a mistake)



          documentclass{minimal}
          usepackage{pgfplotstable}
          usepackage{pgfplots}

          begin{document}
          pgfplotstableread{
          T A B C
          20 0 450 43
          23 0 400 42
          25 0 350 41
          30 0 320 40
          40 0 300 40
          20 10 400 38
          23 10 380 37
          25 10 350 36
          30 10 310 35
          40 10 280 34
          }data

          pgfplotstablesort[sort key={T}]{sorted}{data}

          pgfplotstabletypeset[row predicate/.code={%
          pgfplotstablegetelem{#1}{T}of{sorted}
          ifnumpgfplotsretval=20relax
          elsepgfplotstableuserowfalsefi}]
          {sorted}


          begin{tikzpicture}
          begin{axis}[
          xlabel=A,
          ylabel=B,
          x filter/.code={pgfplotstablegetelem{coordindex}{T}of{sorted}
          ifnumpgfplotsretval=20
          else
          defpgfmathresult{}
          fi
          },
          ]
          addplot[only marks] table[x=A,y=B] {sorted};
          end{axis}
          end{tikzpicture}
          end{document}


          enter image description here



          If the entries of the table involves nonintegers then ifnum would complain hence it needs another step.



          documentclass{minimal}
          usepackage{pgfplotstable}
          usepackage{pgfplots}

          begin{document}
          pgfplotstableread{
          T A B C
          0.567641034 0.111435797 0.886143166 0.536835288
          0.919931469 0.702921973 0.285814111 0.796042178
          0.073058973 0.921420655 0.806947507 0.570962079
          0.697073289 0.017461888 0.313614435 0.905702895
          0.536575411 0.814853755 0.152870278 0.556116015
          0.574615343 0.162798271 0.553041948 0.605668041
          0.567641034 0.248224272 0.448683336 0.092672169
          0.117628849 0.115555917 0.193712749 0.561100742
          0.625852254 0.993854404 0.950034992 0.595500664
          0.975451837 0.152198913 0.647432196 0.790471281
          0.692695418 0.099750965 0.122178502 0.141174403
          0.106974613 0.905644903 0.491119067 0.795346
          0.727907584 0.408384001 0.586645737 0.172061294
          }data

          pgfplotstablesort[sort key={T}]{sorted}{data}



          begin{tikzpicture}
          begin{axis}[
          xlabel=A,
          ylabel=B,
          x filter/.code={pgfplotstablegetelem{coordindex}{T}of{sorted}
          pgfmathtruncatemacro{tempva}{abs(pgfplotsretval - 0.567641034) == 0 ? 1: 0}
          ifnumtempva>0%true
          else%false
          defpgfmathresult{}
          fi
          },
          ]
          addplot[only marks] table[x=A,y=B] {sorted};
          end{axis}
          end{tikzpicture}
          end{document}


          which leads to the same output above. I have modified a table entry as it is almost passing the test if lowered slightly. So you should be careful about the numerical precision.






          share|improve this answer


























          • @Jake Thanks you are right, that's probably the way but when I did that 2 more coordinates from T column value leaks in. Any idea why?

            – percusse
            Aug 7 '12 at 13:38











          • I tried both codes and they worked fine. @percusse Maybe you have the addplot twice in the code.

            – wonder
            Aug 7 '12 at 13:46











          • @wonder @Jake Nevermind, I was supplying the [x=A,y=B] options to addplot instead of table. I'll fix it in a sec.

            – percusse
            Aug 7 '12 at 13:49













          • One additional question: The above discussed filtering/plotting seems only to work with integers. What needs to be changed if there are floats the table?

            – wonder
            Aug 9 '12 at 9:18






          • 2





            @wonder Please give us a part of your real data and state what is missing so we can give a full working answer. This progress, as you might imagine, is only incremental and becomes difficult to address all issues at one shot each time we implement another detail.

            – percusse
            Aug 10 '12 at 9:43














          14












          14








          14







          You can use the x filter/.code={} instructions (thanks to Jake for spotting a mistake)



          documentclass{minimal}
          usepackage{pgfplotstable}
          usepackage{pgfplots}

          begin{document}
          pgfplotstableread{
          T A B C
          20 0 450 43
          23 0 400 42
          25 0 350 41
          30 0 320 40
          40 0 300 40
          20 10 400 38
          23 10 380 37
          25 10 350 36
          30 10 310 35
          40 10 280 34
          }data

          pgfplotstablesort[sort key={T}]{sorted}{data}

          pgfplotstabletypeset[row predicate/.code={%
          pgfplotstablegetelem{#1}{T}of{sorted}
          ifnumpgfplotsretval=20relax
          elsepgfplotstableuserowfalsefi}]
          {sorted}


          begin{tikzpicture}
          begin{axis}[
          xlabel=A,
          ylabel=B,
          x filter/.code={pgfplotstablegetelem{coordindex}{T}of{sorted}
          ifnumpgfplotsretval=20
          else
          defpgfmathresult{}
          fi
          },
          ]
          addplot[only marks] table[x=A,y=B] {sorted};
          end{axis}
          end{tikzpicture}
          end{document}


          enter image description here



          If the entries of the table involves nonintegers then ifnum would complain hence it needs another step.



          documentclass{minimal}
          usepackage{pgfplotstable}
          usepackage{pgfplots}

          begin{document}
          pgfplotstableread{
          T A B C
          0.567641034 0.111435797 0.886143166 0.536835288
          0.919931469 0.702921973 0.285814111 0.796042178
          0.073058973 0.921420655 0.806947507 0.570962079
          0.697073289 0.017461888 0.313614435 0.905702895
          0.536575411 0.814853755 0.152870278 0.556116015
          0.574615343 0.162798271 0.553041948 0.605668041
          0.567641034 0.248224272 0.448683336 0.092672169
          0.117628849 0.115555917 0.193712749 0.561100742
          0.625852254 0.993854404 0.950034992 0.595500664
          0.975451837 0.152198913 0.647432196 0.790471281
          0.692695418 0.099750965 0.122178502 0.141174403
          0.106974613 0.905644903 0.491119067 0.795346
          0.727907584 0.408384001 0.586645737 0.172061294
          }data

          pgfplotstablesort[sort key={T}]{sorted}{data}



          begin{tikzpicture}
          begin{axis}[
          xlabel=A,
          ylabel=B,
          x filter/.code={pgfplotstablegetelem{coordindex}{T}of{sorted}
          pgfmathtruncatemacro{tempva}{abs(pgfplotsretval - 0.567641034) == 0 ? 1: 0}
          ifnumtempva>0%true
          else%false
          defpgfmathresult{}
          fi
          },
          ]
          addplot[only marks] table[x=A,y=B] {sorted};
          end{axis}
          end{tikzpicture}
          end{document}


          which leads to the same output above. I have modified a table entry as it is almost passing the test if lowered slightly. So you should be careful about the numerical precision.






          share|improve this answer















          You can use the x filter/.code={} instructions (thanks to Jake for spotting a mistake)



          documentclass{minimal}
          usepackage{pgfplotstable}
          usepackage{pgfplots}

          begin{document}
          pgfplotstableread{
          T A B C
          20 0 450 43
          23 0 400 42
          25 0 350 41
          30 0 320 40
          40 0 300 40
          20 10 400 38
          23 10 380 37
          25 10 350 36
          30 10 310 35
          40 10 280 34
          }data

          pgfplotstablesort[sort key={T}]{sorted}{data}

          pgfplotstabletypeset[row predicate/.code={%
          pgfplotstablegetelem{#1}{T}of{sorted}
          ifnumpgfplotsretval=20relax
          elsepgfplotstableuserowfalsefi}]
          {sorted}


          begin{tikzpicture}
          begin{axis}[
          xlabel=A,
          ylabel=B,
          x filter/.code={pgfplotstablegetelem{coordindex}{T}of{sorted}
          ifnumpgfplotsretval=20
          else
          defpgfmathresult{}
          fi
          },
          ]
          addplot[only marks] table[x=A,y=B] {sorted};
          end{axis}
          end{tikzpicture}
          end{document}


          enter image description here



          If the entries of the table involves nonintegers then ifnum would complain hence it needs another step.



          documentclass{minimal}
          usepackage{pgfplotstable}
          usepackage{pgfplots}

          begin{document}
          pgfplotstableread{
          T A B C
          0.567641034 0.111435797 0.886143166 0.536835288
          0.919931469 0.702921973 0.285814111 0.796042178
          0.073058973 0.921420655 0.806947507 0.570962079
          0.697073289 0.017461888 0.313614435 0.905702895
          0.536575411 0.814853755 0.152870278 0.556116015
          0.574615343 0.162798271 0.553041948 0.605668041
          0.567641034 0.248224272 0.448683336 0.092672169
          0.117628849 0.115555917 0.193712749 0.561100742
          0.625852254 0.993854404 0.950034992 0.595500664
          0.975451837 0.152198913 0.647432196 0.790471281
          0.692695418 0.099750965 0.122178502 0.141174403
          0.106974613 0.905644903 0.491119067 0.795346
          0.727907584 0.408384001 0.586645737 0.172061294
          }data

          pgfplotstablesort[sort key={T}]{sorted}{data}



          begin{tikzpicture}
          begin{axis}[
          xlabel=A,
          ylabel=B,
          x filter/.code={pgfplotstablegetelem{coordindex}{T}of{sorted}
          pgfmathtruncatemacro{tempva}{abs(pgfplotsretval - 0.567641034) == 0 ? 1: 0}
          ifnumtempva>0%true
          else%false
          defpgfmathresult{}
          fi
          },
          ]
          addplot[only marks] table[x=A,y=B] {sorted};
          end{axis}
          end{tikzpicture}
          end{document}


          which leads to the same output above. I have modified a table entry as it is almost passing the test if lowered slightly. So you should be careful about the numerical precision.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 10 '12 at 8:06

























          answered Aug 7 '12 at 13:14









          percussepercusse

          137k14257495




          137k14257495













          • @Jake Thanks you are right, that's probably the way but when I did that 2 more coordinates from T column value leaks in. Any idea why?

            – percusse
            Aug 7 '12 at 13:38











          • I tried both codes and they worked fine. @percusse Maybe you have the addplot twice in the code.

            – wonder
            Aug 7 '12 at 13:46











          • @wonder @Jake Nevermind, I was supplying the [x=A,y=B] options to addplot instead of table. I'll fix it in a sec.

            – percusse
            Aug 7 '12 at 13:49













          • One additional question: The above discussed filtering/plotting seems only to work with integers. What needs to be changed if there are floats the table?

            – wonder
            Aug 9 '12 at 9:18






          • 2





            @wonder Please give us a part of your real data and state what is missing so we can give a full working answer. This progress, as you might imagine, is only incremental and becomes difficult to address all issues at one shot each time we implement another detail.

            – percusse
            Aug 10 '12 at 9:43



















          • @Jake Thanks you are right, that's probably the way but when I did that 2 more coordinates from T column value leaks in. Any idea why?

            – percusse
            Aug 7 '12 at 13:38











          • I tried both codes and they worked fine. @percusse Maybe you have the addplot twice in the code.

            – wonder
            Aug 7 '12 at 13:46











          • @wonder @Jake Nevermind, I was supplying the [x=A,y=B] options to addplot instead of table. I'll fix it in a sec.

            – percusse
            Aug 7 '12 at 13:49













          • One additional question: The above discussed filtering/plotting seems only to work with integers. What needs to be changed if there are floats the table?

            – wonder
            Aug 9 '12 at 9:18






          • 2





            @wonder Please give us a part of your real data and state what is missing so we can give a full working answer. This progress, as you might imagine, is only incremental and becomes difficult to address all issues at one shot each time we implement another detail.

            – percusse
            Aug 10 '12 at 9:43

















          @Jake Thanks you are right, that's probably the way but when I did that 2 more coordinates from T column value leaks in. Any idea why?

          – percusse
          Aug 7 '12 at 13:38





          @Jake Thanks you are right, that's probably the way but when I did that 2 more coordinates from T column value leaks in. Any idea why?

          – percusse
          Aug 7 '12 at 13:38













          I tried both codes and they worked fine. @percusse Maybe you have the addplot twice in the code.

          – wonder
          Aug 7 '12 at 13:46





          I tried both codes and they worked fine. @percusse Maybe you have the addplot twice in the code.

          – wonder
          Aug 7 '12 at 13:46













          @wonder @Jake Nevermind, I was supplying the [x=A,y=B] options to addplot instead of table. I'll fix it in a sec.

          – percusse
          Aug 7 '12 at 13:49







          @wonder @Jake Nevermind, I was supplying the [x=A,y=B] options to addplot instead of table. I'll fix it in a sec.

          – percusse
          Aug 7 '12 at 13:49















          One additional question: The above discussed filtering/plotting seems only to work with integers. What needs to be changed if there are floats the table?

          – wonder
          Aug 9 '12 at 9:18





          One additional question: The above discussed filtering/plotting seems only to work with integers. What needs to be changed if there are floats the table?

          – wonder
          Aug 9 '12 at 9:18




          2




          2





          @wonder Please give us a part of your real data and state what is missing so we can give a full working answer. This progress, as you might imagine, is only incremental and becomes difficult to address all issues at one shot each time we implement another detail.

          – percusse
          Aug 10 '12 at 9:43





          @wonder Please give us a part of your real data and state what is missing so we can give a full working answer. This progress, as you might imagine, is only incremental and becomes difficult to address all issues at one shot each time we implement another detail.

          – percusse
          Aug 10 '12 at 9:43


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f66177%2fhow-can-i-filter-select-data-from-a-table-and-plot-it%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Accessing regular linux commands in Huawei's Dopra Linux

          Can't connect RFCOMM socket: Host is down

          Kernel panic - not syncing: Fatal Exception in Interrupt