7
votes

I can plot parallel coordinates graphs with Gnuplot 5.0. For example:

plot "ranking_top10.dat" using 4:5:6:7:8:2 with parallel lt 1 lc variable

will plot 5 axes, and lines in different colors. However, I want to associate keys with each of those lines. For example, I want to associate a key (string) with the purple line and show it on the figure. How to do that?

parallel_axes

1

1 Answers

0
votes

This question is pretty "old" but still unanswered. Maybe an answer is still of interest. Unfortunately, you haven't provided the full code and data to generate your plot.

In your case, I'm not aware of an easy and direct way generating the key automatically. So the workaround is to do put the titles and colors into a string via plotting to a dummy table and also dummy-plotting NaN just to get the legend/key. Tested with gnuplot 5.0.0 and 5.2.6

Code:

### parallel plot with proper keys
reset session

$Data <<EOD
1   1   "Set A"   5000    30000    51  0.35 0.23
2   2   "Set B"   8000    80000    20  0.5  -0.5
3   3   "Set C"   6000    20000    38  0.75 0.12
4   4   "Set D"   8000    50000    17  1.9  0.32
5   5   "Set E"   70000   110000   62  2.99 0.5
6   6   "Set F"   0       0        0   0    0
7   7   "Set G"   40000   130000   38  0.80 -0.05
8   8   "Set H"   3000    30000    19  0.55 0.1
9   6   "Set I"   11000   50000    22  1.75 0.12
EOD

unset border
set key out top right
set xrange[0.2:5.5]
set xtics 1 format "axis %g" scale 0,0
unset ytics

set for [i=1:5] paxis i tics format "%g" right offset 1.5,0  # ok for gnuplot 5.2.6
# set paxis 3 tics format "%g" right offset -1,0             # required (uncomment) for gnuplot 5.0.0

# create titles and colors
myTitles = myColors = ""
set table $Dummy
    plot $Data u (myTitles = myTitles.'"'.strcol(3).'" '), \
         '' u (myColors = myColors.sprintf("%g ",column(2))) w table
unset table

plot $Data u 4:5:6:7:8:2 w parallel lw 2 lc var not, \
     for [i=1:9] NaN w l lw 2 lc word(myColors,i) ti word(myTitles,i)
### end of code

Result:

enter image description here