Thread: GNUPlot Help

  1. #1
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278

    GNUPlot Help

    I am doing a C program that calculates the "closest pair" among the points given in an input file.

    POINTS.TXT
    Code:
    2 3
    8 9
    10 7
    4 5
    Now my objective is to plot the points using GNUPlot and draw a line between the closest pair of points. I have succeed in drawing the points but am unable to draw line between two specific points.

    Command I have used to plot the points:-

    Code:
    plot "points.txt"
    I need command to draw line between 2 points please.

  2. #2
    Just a pushpin. bernt's Avatar
    Join Date
    May 2009
    Posts
    426
    gnuplot / intro / style

    I suppose you could list the 2 points separate from the others, and plot them with the "lines" or "vectors" style.

    points.txt:
    Code:
    #data
    2 3
    8 9
    10 7
    4 5
    
    
    #note: 2 blank lines separate data sets
    #points to draw lines between
    2 3
    4 5
    then in gnuplot:
    Code:
    plot "points.txt" index 0, "points.txt" index 1 with lines
    Consider this post signed

  3. #3
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278
    Oh thanks a billion.

    Still 2 more query please.

    1. How to change the color of the line? It is appearing Green in Windows.
    2. How to change the appearance of the points? It is appearing like cross mark in Windows.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by anirban View Post
    Oh thanks a billion.

    Still 2 more query please.

    1. How to change the color of the line? It is appearing Green in Windows.
    2. How to change the appearance of the points? It is appearing like cross mark in Windows.
    So -- crazy I know -- but have you typed "help plot" in gnuplot? The "with" part allows you to change linecolor, pointstyle, pointsize, etc.

  5. #5
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413
    A little late, but I'd just like to say that my encounters with GNUPlot have been crappy at best, PLplot is vastly superior, check it out: PLplot Home Page - Main

  6. #6
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278
    Okay thanks but I need just once to give a demo to my teacher.
    So I am happy with GNUPlot and your nice help!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gnuplot and C programming
    By bartleby84 in forum C Programming
    Replies: 6
    Last Post: 04-30-2010, 02:53 PM
  2. gnuplot & C++
    By wolfindark in forum C++ Programming
    Replies: 3
    Last Post: 01-19-2010, 09:03 AM
  3. GNUPLOT: Plotting multiple files.
    By waynex in forum Tech Board
    Replies: 3
    Last Post: 01-18-2008, 06:58 AM
  4. gnuplot question
    By vutek0328 in forum Tech Board
    Replies: 1
    Last Post: 11-09-2006, 06:40 AM
  5. gnuplot
    By siubo in forum C Programming
    Replies: 3
    Last Post: 04-16-2003, 10:31 AM