Create scientific plots using gnuplot

October 6th, 2010 | 24 Comments

If we want to plot a single point, we can do this by creating a data file, containing only one line:

# x   y
1   2

But there exist an easier method without any additional data file. In Fig. 1 three points with different symbols are plotted.

Three points

Fig. 1 Plot of three single points (code to produce this figure)

To achieve this we just use the following command:

plot '-' w p ls 1, '-' w p ls 2, '-' w p ls 3
1 2
2 1
3 1.5

We use the possibility to tell Gnuplot with the '-' input to read from standard input. Here we tell Gnuplot to do this three times. After the plot command the data is entered. Every single data entry have to ended with the e line.
In order to have different symbols for the points we set them before:

set style line 1 lc rgb 'black' pt 5   # square
set style line 2 lc rgb 'black' pt 7   # circle
set style line 3 lc rgb 'black' pt 9   # triangle

Note: if we want to use the replot command then the above code will not work probably. But the same can be achieved by using:

plot "<echo '1 2'"   with points ls 1, \
     "<echo '2 1'"   with points ls 2, \
     "<echo '3 1.5'" with points ls 3


  1. Morri says:

    This was really helpful.

    When I plot using the open symbols like pt 4 or pt 6 they always have a little dot in the center. Is there anyway to avoid this?


  2. hagen says:

    Yes, I know the annoying little dot at the center.
    I’m using mostly postscript (eps) files. After plotting I open them in Inkscape and remove the little dot.
    For png or other terminals I have no solution at the moment.

  3. […] es una traducción a Español de un post en inglés. Me pareció interesante proporcionar esta información traducida al español. Espero que sea de […]

  4. Johne572 says:

    I really like your blog.. very nice colors &amp theme. Did you make this website yourself or did you hire someone to do it for you? Plz respond as I’m looking to construct my own blog and would like to know where u got this from. thank you fegbdefffeae

  5. hagen says:

    Hi Johne,
    I made it by myself using Bootstrap as a basis which is a very good start if you have some HTML/CSS knowledge. The color theme is inspired by Tarski which I used for an early version of the blog.

  6. Iulian says:

    Thank you very very very much! That article helped me a lot!

  7. Tim says:

    Makes me think

    plot "<echo 1 1" using (ax):(ay)

    This is a bit of an abuse, but useful for calculated locations.

  8. hagen says:

    That’s true and it can be formulated even shorter using the special filename

    plot '+' using (ax):(ay)
  9. lev says:
    plot "echo ax ay" w p pt n
  10. lev says:


    plot “< echo ax ay” w p pt n

    ax, ay do not need to be preset, you may write your numbers straight after "< echo"

  11. Joe says:

    How does this work with variables? i just get
    Bad data on line 1 of file < echo ax ay

    But it does seem to work with explicit numbers.

  12. hagen says:

    Hi Joe.

    The easiest way is the one stated above

    plot '+' using (ax):(ay)

    Otherwise you can do

    plot "<echo ".ax." ".ay
  13. SRISHTI NAGU says:

    Please some one tell how to make a best fit point in contour plots using gnuplot ??

    Thank you

  14. PAOK says:

    Bolches yarboclos

    This doesn’t work

  15. Thanks , I’ve recently been searching for information approximately
    this topic for a while and yours is the best I’ve came upon so far.
    However, what about the bottom line? Aree you positiive in regards to the source?

    Feel free to surf to my page :: See This Website Gives Reviews Of Wick Drain Suppliers

  16. Hi there very nice blog!! Man .. Beautiful .. Wonderful .. I will bookmark your site and take the feeds additionally?KI am happy to search out a lot of useful information right here in the put up, we want work out extra strategies in this regard, thanks for sharing. . . . . .

  17. Having read this I believed it was rather informative.
    I appreciate you spending some time and effort to put this content
    together. Iojce again find myself spending a lot of time both reading and posting comments.
    But so what, it was still worthwhile!

    Stop bby my homepage Linked Web Site About Soil Stabilization Methods

  18. Bentley says:

    Hi there, all is going sound here and ofcourse every one is
    sharing facts, that’s really good, keep up writing.

  19. Hello just wanted to give you a brief heads up and
    let you know a few of the images aren’t loading correctly.

    I’m not sure why but I think its a linking issue.

    I’ve tried it in two different web browsers and both show the same results.

    My page … Refer to This page to discuss prefabricated vertical drain installation

  20. Heya i’m for the first time here. I found this board and I find It really useful & it helped me out much. I hope to give something back and aid others like you helped me.

  21. Did you write the article yourself or you hired someone to
    do it? I was wondering because I am a site owner too
    and struggle with writing new content all the time. Someone told me to use AI to do create articles which I am kinda considering because the output is almost written by human.
    Here is the sample content they sent me –

    Let me know if you think I should go ahead and use AI.

  22. Hi to every one, it’s genuinely a good for me to visit this website, it contains precious Information.

  23. With havin so much content and articles do you ever run into any issues of plagorism
    or copyright violation? My website has a lot of
    unique content I’ve either created myself or outsourced but
    it seems a lot of it is popping it up all over the web without my permission. Do
    you know any techniques to help protect against content from being ripped off?

    I’d genuinely appreciate it.

Leave a Reply