0

Lets assume we have a data like :

1383.77224864627    1910.27446956287    13
2022.08962783969    1870.75968662608    13
2244.59435149955    2334.43843428841    13
3223.73010669775    2409.90834407782    15
708.364446053354    3199.82702811616    15
1190.6942303025     2634.33363259192    15
1749.15599203783    2716.76870380272    19
2227.80906774024    3119.99529267007    19

Is it possible to plot series, based on values in the 3rd column ?

Desired result in this example would be to have 3 series with different colors on one plot.

I'm aware that I can create new series with :

plot 'datafile' using col1:col2, '' using col1:col3

or by using new line between series in datafile but thats not I would like to do.

Thanks ! Edit: I'm using gnuplot version 5.0

ewcz
  • 12,819
  • 1
  • 25
  • 47
zbyszekt
  • 151
  • 1
  • 10
  • Are you saying that you want col3 on the x axis and cols 1 and 3 on the y axis? If not, pls explain what the outcome should look like. – vaettchen Jan 06 '18 at 23:31
  • I want to plot a scatter chart, where first and second column is the (x,y), and the 3rd value distinguish a series. Using the example from question, I would like to have a 3 series of points plotted - every series with different color - 3 points would come from series '13', 3 points from series '15', and 2 points from series '19'. – zbyszekt Jan 07 '18 at 10:34
  • Does [that](https://stackoverflow.com/questions/8717805/how-to-make-points-one-color-when-a-third-column-equals-zero-and-another-color/8728339#8728339) help? – vaettchen Jan 07 '18 at 11:04

2 Answers2

1

You would need to filter the datafile first and then plot individual parts separately:

#prepare the command responsible for filtering the data file of interest
#select all rows the value in the 3rd column of which is equal to val
filterData(fname, val)=sprintf("<gawk '$3==%d' %s", val, fname)

#show individual dependencies in one plot
plot for [sval in "13 15"] \
    filterData('datafile.dat', int(sval)) w lp t sprintf('value %s', sval)

This would give you: enter image description here

ewcz
  • 12,819
  • 1
  • 25
  • 47
1

Building on my 2012 answer and my understanding of what you want, this should help:

set palette defined ( 13 "blue", 15 "red", 19 "green")
unset key
unset colorbox
plot [500:3500][1800:3500] "x" u 1:2:3 with points palette ps 3 pt 5

which yields

enter image description here

EDIT:

One could also define a continuous palette and let the actual colors be allocated depending upon their value within that scale. In practice:

set palette defined ( 0 "blue", 20 "green", 40 "red")
unset key
set colorbox                              # for demo purpose
plot [500:3500][1800:3500] "x" u 1:2:3 with points palette ps 3 pt 7

which brings

enter image description here

for the given data set. Colors will change when new series is added.

vaettchen
  • 7,299
  • 22
  • 41
  • That's exactly what I want to achieve, but there is no way to *not* use custom palette ? I have like 25 possible series, so I need to define entirely new palette that consist of 25 colors each time ? – zbyszekt Jan 07 '18 at 12:28
  • See edited example, although I wonder whether such a plot provides enough clarity - but that's your call... – vaettchen Jan 07 '18 at 12:44
  • I do not see any changes in your post. This will be a cluster coloring plot, so it will work fine :) – zbyszekt Jan 07 '18 at 12:51
  • As you said, the scale does not work - too many similar colors :) https://www2.uni-hamburg.de/Wiss/FB/15/Sustainability/schneider/gnuplot/colors.htm Nice list of colors to use. Thanks ! – zbyszekt Jan 07 '18 at 13:08