create scatter plot












1















file (1. arg) will create (scatter plot) for n. column (x-axis, 2. arg) and m. column (y-axis, 3. arg)



function is called myfun sourcefile 1 3 for scatter plot of 1. and 3. column from file sourcefile.



#!/bin/bash/gnuplot

myfun(){
plot "$1" using $2:$3
}
myfun sourcefile 1 3


In gnuplot> plot sourcefile using 1:3 works perfectly. I want it to run inside the function. How?










share|improve this question





























    1















    file (1. arg) will create (scatter plot) for n. column (x-axis, 2. arg) and m. column (y-axis, 3. arg)



    function is called myfun sourcefile 1 3 for scatter plot of 1. and 3. column from file sourcefile.



    #!/bin/bash/gnuplot

    myfun(){
    plot "$1" using $2:$3
    }
    myfun sourcefile 1 3


    In gnuplot> plot sourcefile using 1:3 works perfectly. I want it to run inside the function. How?










    share|improve this question



























      1












      1








      1








      file (1. arg) will create (scatter plot) for n. column (x-axis, 2. arg) and m. column (y-axis, 3. arg)



      function is called myfun sourcefile 1 3 for scatter plot of 1. and 3. column from file sourcefile.



      #!/bin/bash/gnuplot

      myfun(){
      plot "$1" using $2:$3
      }
      myfun sourcefile 1 3


      In gnuplot> plot sourcefile using 1:3 works perfectly. I want it to run inside the function. How?










      share|improve this question
















      file (1. arg) will create (scatter plot) for n. column (x-axis, 2. arg) and m. column (y-axis, 3. arg)



      function is called myfun sourcefile 1 3 for scatter plot of 1. and 3. column from file sourcefile.



      #!/bin/bash/gnuplot

      myfun(){
      plot "$1" using $2:$3
      }
      myfun sourcefile 1 3


      In gnuplot> plot sourcefile using 1:3 works perfectly. I want it to run inside the function. How?







      bash scripts functions gnuplot plot






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 9 '18 at 8:39









      karel

      57.8k12128146




      57.8k12128146










      asked Jun 29 '15 at 14:47









      Martin YeboahMartin Yeboah

      10619




      10619






















          2 Answers
          2






          active

          oldest

          votes


















          2














          I'd suggest using a shell here document in this case



          #!/bin/bash

          function myfun {
          cat << EOF | gnuplot -p
          plot "$1" using $2:$3
          EOF
          }


          Then



          myfun sourcefile 1 3





          share|improve this answer
























          • thanks, but anytime I execute it, I get the script on the screen. No graph :/

            – Martin Yeboah
            Jun 29 '15 at 17:04











          • Thanks soo much :) It now somehow works :D :D :D :D :D :D :D

            – Martin Yeboah
            Jun 29 '15 at 17:07











          • what is "E0F" ? and why do we need it ? also <<

            – Martin Yeboah
            Jun 29 '15 at 17:14






          • 1





            @MartinYeboah did you read the wikipedia link? EOF is just a END_TEXT marker. You can use pretty much any string: EOF (end of file) or EOD (end of data) are just common choices

            – steeldriver
            Jun 29 '15 at 17:52



















          2














          I really do not know what kind of script is that one. Where did you find it? .../bash/gnuplot seems that someone is getting really confused.



          But if you have the file with the data, call it sourcefile, with the structure



          whatever  x-data y-data
          whatever x-data y-data
          whatever x-data y-data


          you can have a scatter plot of column 3 versus column 2 entering gnuplot, and at the prompt using:



          plot "sourcefile" using 2:3


          (Although your script seems to be doing plot "sourcefile" using 1:3, in contrast with your description, and without quotes which is a syntax error in gnuplot unless sourcefile is a variable containing the name of the file).



          I recommend you to read http://people.duke.edu/~hpgavin/gnuplot.html






          share|improve this answer
























          • Thank you! I can create the scatterplot in gnu-plot like how you suggested. But I want to execute it inside the function too.. :(

            – Martin Yeboah
            Jun 29 '15 at 16:26











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2faskubuntu.com%2fquestions%2f642364%2fcreate-scatter-plot%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          I'd suggest using a shell here document in this case



          #!/bin/bash

          function myfun {
          cat << EOF | gnuplot -p
          plot "$1" using $2:$3
          EOF
          }


          Then



          myfun sourcefile 1 3





          share|improve this answer
























          • thanks, but anytime I execute it, I get the script on the screen. No graph :/

            – Martin Yeboah
            Jun 29 '15 at 17:04











          • Thanks soo much :) It now somehow works :D :D :D :D :D :D :D

            – Martin Yeboah
            Jun 29 '15 at 17:07











          • what is "E0F" ? and why do we need it ? also <<

            – Martin Yeboah
            Jun 29 '15 at 17:14






          • 1





            @MartinYeboah did you read the wikipedia link? EOF is just a END_TEXT marker. You can use pretty much any string: EOF (end of file) or EOD (end of data) are just common choices

            – steeldriver
            Jun 29 '15 at 17:52
















          2














          I'd suggest using a shell here document in this case



          #!/bin/bash

          function myfun {
          cat << EOF | gnuplot -p
          plot "$1" using $2:$3
          EOF
          }


          Then



          myfun sourcefile 1 3





          share|improve this answer
























          • thanks, but anytime I execute it, I get the script on the screen. No graph :/

            – Martin Yeboah
            Jun 29 '15 at 17:04











          • Thanks soo much :) It now somehow works :D :D :D :D :D :D :D

            – Martin Yeboah
            Jun 29 '15 at 17:07











          • what is "E0F" ? and why do we need it ? also <<

            – Martin Yeboah
            Jun 29 '15 at 17:14






          • 1





            @MartinYeboah did you read the wikipedia link? EOF is just a END_TEXT marker. You can use pretty much any string: EOF (end of file) or EOD (end of data) are just common choices

            – steeldriver
            Jun 29 '15 at 17:52














          2












          2








          2







          I'd suggest using a shell here document in this case



          #!/bin/bash

          function myfun {
          cat << EOF | gnuplot -p
          plot "$1" using $2:$3
          EOF
          }


          Then



          myfun sourcefile 1 3





          share|improve this answer













          I'd suggest using a shell here document in this case



          #!/bin/bash

          function myfun {
          cat << EOF | gnuplot -p
          plot "$1" using $2:$3
          EOF
          }


          Then



          myfun sourcefile 1 3






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 29 '15 at 16:49









          steeldriversteeldriver

          66.2k11106179




          66.2k11106179













          • thanks, but anytime I execute it, I get the script on the screen. No graph :/

            – Martin Yeboah
            Jun 29 '15 at 17:04











          • Thanks soo much :) It now somehow works :D :D :D :D :D :D :D

            – Martin Yeboah
            Jun 29 '15 at 17:07











          • what is "E0F" ? and why do we need it ? also <<

            – Martin Yeboah
            Jun 29 '15 at 17:14






          • 1





            @MartinYeboah did you read the wikipedia link? EOF is just a END_TEXT marker. You can use pretty much any string: EOF (end of file) or EOD (end of data) are just common choices

            – steeldriver
            Jun 29 '15 at 17:52



















          • thanks, but anytime I execute it, I get the script on the screen. No graph :/

            – Martin Yeboah
            Jun 29 '15 at 17:04











          • Thanks soo much :) It now somehow works :D :D :D :D :D :D :D

            – Martin Yeboah
            Jun 29 '15 at 17:07











          • what is "E0F" ? and why do we need it ? also <<

            – Martin Yeboah
            Jun 29 '15 at 17:14






          • 1





            @MartinYeboah did you read the wikipedia link? EOF is just a END_TEXT marker. You can use pretty much any string: EOF (end of file) or EOD (end of data) are just common choices

            – steeldriver
            Jun 29 '15 at 17:52

















          thanks, but anytime I execute it, I get the script on the screen. No graph :/

          – Martin Yeboah
          Jun 29 '15 at 17:04





          thanks, but anytime I execute it, I get the script on the screen. No graph :/

          – Martin Yeboah
          Jun 29 '15 at 17:04













          Thanks soo much :) It now somehow works :D :D :D :D :D :D :D

          – Martin Yeboah
          Jun 29 '15 at 17:07





          Thanks soo much :) It now somehow works :D :D :D :D :D :D :D

          – Martin Yeboah
          Jun 29 '15 at 17:07













          what is "E0F" ? and why do we need it ? also <<

          – Martin Yeboah
          Jun 29 '15 at 17:14





          what is "E0F" ? and why do we need it ? also <<

          – Martin Yeboah
          Jun 29 '15 at 17:14




          1




          1





          @MartinYeboah did you read the wikipedia link? EOF is just a END_TEXT marker. You can use pretty much any string: EOF (end of file) or EOD (end of data) are just common choices

          – steeldriver
          Jun 29 '15 at 17:52





          @MartinYeboah did you read the wikipedia link? EOF is just a END_TEXT marker. You can use pretty much any string: EOF (end of file) or EOD (end of data) are just common choices

          – steeldriver
          Jun 29 '15 at 17:52













          2














          I really do not know what kind of script is that one. Where did you find it? .../bash/gnuplot seems that someone is getting really confused.



          But if you have the file with the data, call it sourcefile, with the structure



          whatever  x-data y-data
          whatever x-data y-data
          whatever x-data y-data


          you can have a scatter plot of column 3 versus column 2 entering gnuplot, and at the prompt using:



          plot "sourcefile" using 2:3


          (Although your script seems to be doing plot "sourcefile" using 1:3, in contrast with your description, and without quotes which is a syntax error in gnuplot unless sourcefile is a variable containing the name of the file).



          I recommend you to read http://people.duke.edu/~hpgavin/gnuplot.html






          share|improve this answer
























          • Thank you! I can create the scatterplot in gnu-plot like how you suggested. But I want to execute it inside the function too.. :(

            – Martin Yeboah
            Jun 29 '15 at 16:26
















          2














          I really do not know what kind of script is that one. Where did you find it? .../bash/gnuplot seems that someone is getting really confused.



          But if you have the file with the data, call it sourcefile, with the structure



          whatever  x-data y-data
          whatever x-data y-data
          whatever x-data y-data


          you can have a scatter plot of column 3 versus column 2 entering gnuplot, and at the prompt using:



          plot "sourcefile" using 2:3


          (Although your script seems to be doing plot "sourcefile" using 1:3, in contrast with your description, and without quotes which is a syntax error in gnuplot unless sourcefile is a variable containing the name of the file).



          I recommend you to read http://people.duke.edu/~hpgavin/gnuplot.html






          share|improve this answer
























          • Thank you! I can create the scatterplot in gnu-plot like how you suggested. But I want to execute it inside the function too.. :(

            – Martin Yeboah
            Jun 29 '15 at 16:26














          2












          2








          2







          I really do not know what kind of script is that one. Where did you find it? .../bash/gnuplot seems that someone is getting really confused.



          But if you have the file with the data, call it sourcefile, with the structure



          whatever  x-data y-data
          whatever x-data y-data
          whatever x-data y-data


          you can have a scatter plot of column 3 versus column 2 entering gnuplot, and at the prompt using:



          plot "sourcefile" using 2:3


          (Although your script seems to be doing plot "sourcefile" using 1:3, in contrast with your description, and without quotes which is a syntax error in gnuplot unless sourcefile is a variable containing the name of the file).



          I recommend you to read http://people.duke.edu/~hpgavin/gnuplot.html






          share|improve this answer













          I really do not know what kind of script is that one. Where did you find it? .../bash/gnuplot seems that someone is getting really confused.



          But if you have the file with the data, call it sourcefile, with the structure



          whatever  x-data y-data
          whatever x-data y-data
          whatever x-data y-data


          you can have a scatter plot of column 3 versus column 2 entering gnuplot, and at the prompt using:



          plot "sourcefile" using 2:3


          (Although your script seems to be doing plot "sourcefile" using 1:3, in contrast with your description, and without quotes which is a syntax error in gnuplot unless sourcefile is a variable containing the name of the file).



          I recommend you to read http://people.duke.edu/~hpgavin/gnuplot.html







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 29 '15 at 15:56









          RmanoRmano

          25.2k878145




          25.2k878145













          • Thank you! I can create the scatterplot in gnu-plot like how you suggested. But I want to execute it inside the function too.. :(

            – Martin Yeboah
            Jun 29 '15 at 16:26



















          • Thank you! I can create the scatterplot in gnu-plot like how you suggested. But I want to execute it inside the function too.. :(

            – Martin Yeboah
            Jun 29 '15 at 16:26

















          Thank you! I can create the scatterplot in gnu-plot like how you suggested. But I want to execute it inside the function too.. :(

          – Martin Yeboah
          Jun 29 '15 at 16:26





          Thank you! I can create the scatterplot in gnu-plot like how you suggested. But I want to execute it inside the function too.. :(

          – Martin Yeboah
          Jun 29 '15 at 16:26


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • 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%2faskubuntu.com%2fquestions%2f642364%2fcreate-scatter-plot%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

          How to change which sound is reproduced for terminal bell?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

          Can I use Tabulator js library in my java Spring + Thymeleaf project?