[gnuplot] Label the x-axis using the numbers from two columns as strings

08 Mar

Let’s look at an example data file first:

+2   +2   10.0
+1   +1    9.0
 0    0    7.8
+1   -1   17.0
+2   -2    1.2

We want to plot the numbers in the third column in the y-axis with (+2,+2), (+1,+1), .., (+2,-2) as the corresponding x-values.

There are two aspects to deal with here, namely
(1) to use strings as (x)tic labels —>  xticlabels function can handle that.
(2) to combine two numbers in two different columns into a single string —> sprintf function can handle that.

Here’s what a sample gnuplot command would look like

gnuplot> plot using ($0):3:xticlabels( sprintf("(%+d,%+d)",$1,$2) ) with linespoints

About these ads
Leave a comment

Posted by on March 8, 2013 in plot


Tags: , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 34 other followers

%d bloggers like this: