Reputation: 305
I have a data set with two columns, (x,y)
which looks like:
4 16
1 1
5 25
3 9
7 49
0 0
2 4
Now I want to plot this in gnuplot u 1:2
in the order in which column 1 is arranged. Basically on x-axis, gnuplot should have first 4, then 1, then 5 and so on. Is it possible with gnuplot or any other plotting tool?
Upvotes: 0
Views: 324
Reputation: 69116
Since you also tagged matplotlib
, here's a quick script to make the same plot. You just need to plot y
, then set the xticklabels
to x
.
import matplotlib.pyplot as plt
import numpy as np
x,y = np.genfromtxt('data.txt',unpack=True)
plt.plot(y,'ko-')
plt.gca().set_xticklabels(x)
plt.show()
Upvotes: 1
Reputation: 48390
With gnuplot you can use the row number as x-value and use the value from the first column as xtic labels:
plot 'data.txt' using 0:2:xtic(1) w lp pt 7 lw 2
Upvotes: 4