matching points in Gnuplot


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers matching points in Gnuplot
# 1  
Old 10-05-2009
Question matching points in Gnuplot

Does anyone know how can one draw lines between 2 sets of data for the same point.

let's say that the three points

(x1,y1) = (1,2) (4,5) (8.9)

became:
(x2,y2) = (3,6) (6,4) (4, 0)

so if I want to plot these points and match every (x1,y1) with the corresponding (x2,y2), how can I do it?
Any idea??
# 2  
Old 10-07-2009
Does the question make sense?
# 3  
Old 10-08-2009
Hi.

This is one method that I've found so far. It consists of splitting up the data in separate files, then using the mulitplot command to place the plot on top on one another. So there is a driver script, a file of commands, and files of data points. This is a demonstration with the terminal (very low resolution, but easily pastable):
Code:
#!/usr/bin/env bash

# @(#) s2	Demonstrate gnuplot multiplot for connecting point pairs.
# http://www.gnuplot.info/docs/gnuplot.html

echo
set +o nounset
LC_ALL=C ; LANG=C ; export LC_ALL LANG
echo "Environment: LC_ALL = $LC_ALL, LANG = $LANG"
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version "=o" $(_eat $0 $1) gnuplot my-nl
set -o nounset
echo

FILE=${1-data1}

echo " Commands file $FILE:"
cat $FILE

echo
echo " Data files, point*:"
my-nl point*

echo
echo " Results:"
gnuplot $FILE 

exit 0

Producing:
Code:
% ./s2 data5

Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian GNU/Linux 5.0 
GNU bash 3.2.39
gnuplot 4.2 patchlevel 2 
my-nl (local) 296

 Commands file data5:
# set terminal postscript eps colour
set terminal dumb 40 20
set multiplot
set xrange [-1:15]
set yrange [-1:15]
unset autoscale xy
# set size 1,1
# set origin 0,0
# Input file contains comma-separated values fields
set datafile separator ","
plot 'points.1' with lines
plot 'points.2' with lines
plot 'points.3' with lines
unset multiplot

 Data files, point*:

==> points.1 <==

  1 1.0,2.0
  2 3.0,6.0

==> points.2 <==

  1 4,5
  2 6,4

==> points.3 <==

  1 8,9
  2 4,0

 Results:


     +-+---+---+---+---+---+---+---+-+
  14 +++   +   +   'points.1' ******++
     |                               |
  12 ++                             ++
     |                               |
  10 ++                             ++
     |                 *             |
   8 ++                *            ++
     |                *              |
   6 ++      *       *              ++
     |      *  **** *                |
   4 ++    *       **               ++
     |    *        *                 |
   2 ++  *        *                 ++
     |           *                   |
   0 +++   +   *   +   +   +   +   +++
     +-+---+---+---+---+---+---+---+-+
       0   2   4   6   8   10  12  14

If this is the easiest (or only) method, then the real problem will be to separate the data points with a script to avoid error-prone manual data manipulation.

Perhaps someone will stop in to show us a better method ... cheers, drl
# 4  
Old 10-09-2009
Quote:
Originally Posted by drl
Hi.

This is one method that I've found so far. It consists of splitting up the data in separate files, then using the mulitplot command to place the plot on top on one another. So there is a driver script, a file of commands, and files of data points. This is a demonstration with the terminal (very low resolution, but easily pastable):
Code:
#!/usr/bin/env bash

# @(#) s2    Demonstrate gnuplot multiplot for connecting point pairs.
# http://www.gnuplot.info/docs/gnuplot.html

echo
set +o nounset
LC_ALL=C ; LANG=C ; export LC_ALL LANG
echo "Environment: LC_ALL = $LC_ALL, LANG = $LANG"
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version "=o" $(_eat $0 $1) gnuplot my-nl
set -o nounset
echo

FILE=${1-data1}

echo " Commands file $FILE:"
cat $FILE

echo
echo " Data files, point*:"
my-nl point*

echo
echo " Results:"
gnuplot $FILE 

exit 0

Producing:
Code:
% ./s2 data5

Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian GNU/Linux 5.0 
GNU bash 3.2.39
gnuplot 4.2 patchlevel 2 
my-nl (local) 296

 Commands file data5:
# set terminal postscript eps colour
set terminal dumb 40 20
set multiplot
set xrange [-1:15]
set yrange [-1:15]
unset autoscale xy
# set size 1,1
# set origin 0,0
# Input file contains comma-separated values fields
set datafile separator ","
plot 'points.1' with lines
plot 'points.2' with lines
plot 'points.3' with lines
unset multiplot

 Data files, point*:

==> points.1 <==

  1 1.0,2.0
  2 3.0,6.0

==> points.2 <==

  1 4,5
  2 6,4

==> points.3 <==

  1 8,9
  2 4,0

 Results:


     +-+---+---+---+---+---+---+---+-+
  14 +++   +   +   'points.1' ******++
     |                               |
  12 ++                             ++
     |                               |
  10 ++                             ++
     |                 *             |
   8 ++                *            ++
     |                *              |
   6 ++      *       *              ++
     |      *  **** *                |
   4 ++    *       **               ++
     |    *        *                 |
   2 ++  *        *                 ++
     |           *                   |
   0 +++   +   *   +   +   +   +   +++
     +-+---+---+---+---+---+---+---+-+
       0   2   4   6   8   10  12  14

If this is the easiest (or only) method, then the real problem will be to separate the data points with a script to avoid error-prone manual data manipulation.

Perhaps someone will stop in to show us a better method ... cheers, drl


Wow, this seems to complicated to me Smilie Smilie
I am really shocked actually that there is no easy way to draw a vector from an old to a new x,y position... that's really sad Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Gnuplot script

Need assistance in getting a script right. It requires little tweaking and I am not getting it right . Using below data and the below script it creates a table with png file but regarding the time it create 6,7,8 and i want each time 6:15 ,6:30 and so on So that i can view the exact graph... (3 Replies)
Discussion started by: ajayram_arya
3 Replies

2. Shell Programming and Scripting

Gnuplot 3d binning

Hello I have a text file with tens of thousands of rows The format is x y where both x and y can be anything between -100 and +100. What I would like to do is have a 3d gnuplot where there are 10,000 squared or bins and each bin will count how many rows have a value that would be... (1 Reply)
Discussion started by: garethsays
1 Replies

3. Shell Programming and Scripting

Gnuplot question

Hi! Let's say I have these two columns in file.txt 0 1 1 5 2 10 3 15 4 20 5 25 in gnuplot, i would plot usingplot 'file.txt' u 1:2 If I wanted to add a label to the y-axis I would useset label "Ef" at 0.0,7.0 However, I want the label Ef to be on the otherside of the y-axis. Not... (0 Replies)
Discussion started by: sidiq1983
0 Replies

4. Shell Programming and Scripting

Compare file1 for matching line in file2 and print the difference in matching lines

Hello, I have two files file 1 and file 2 each having result of a query on certain database tables and need to compare for Col1 in file1 with Col3 in file2, compare Col2 with Col4 and output the value of Col1 from File1 which is a) not present in Col3 of File2 b) value of Col2 is different from... (2 Replies)
Discussion started by: RasB15
2 Replies

5. Programming

GNUPLOT- how to change the style of data points

Hi, I am trying to arrange my graphs with GNUPLOT. Although it looked like simple at the beginning, I could not figure out an answer for the following: I want to change the style of my data points (not the line, just exact data points) The terminal assigns first + and then x to them but what I... (0 Replies)
Discussion started by: natasha
0 Replies

6. Shell Programming and Scripting

xargs and gnuplot

Hi All, Seems I have an xargs stdin problem that I don't understand. I have a script (call it myscript.sh) that takes the names of one or more file(s) specified on the command line and creates a single gnuplot command file containing multiple records, one for each specified file. Each of... (9 Replies)
Discussion started by: paulianna2002
9 Replies

7. UNIX and Linux Applications

GNUplot

Hi, I am trying to make a plot of an ASCII file using GNUplot, but I keep getting error msg: for example plot filename.txt It says that (.txt ) is not identified ... I tried to write it without the .txt part, but I also get the error msg. Any idea why? :confused: (1 Reply)
Discussion started by: cosmologist
1 Replies

8. UNIX and Linux Applications

Gnuplot question: how to plot 3D points as colored points in map view?

I have a simple gnuplot question. I have a set of points (list of x,y,z values; irregularly spaced, i.e. no grid) that I want to plot. I want the plot to look like this: - points in map view (no 3D view) - color of each point should depend on its z-value. - I want to define my own color scale -... (0 Replies)
Discussion started by: karman
0 Replies

9. UNIX for Dummies Questions & Answers

Help with gnuplot

Hi, I am a beginner using UNIX, and was wondering how to use gnuplot from UNIX on my pc. I am connected remotely to my work's UNIX server using Secure Shell Client, and gnuplot won't open a new window when I use the plot command. How do I do this? Moreover, is it possible to save things from the... (0 Replies)
Discussion started by: KTTFB64
0 Replies
Login or Register to Ask a Question