Thibault Langlois
Thibault Langlois

Reputation: 99

in gnuplot how do i set a key (legend) when using "plot with labels"

When I use "plot with labels" with various groups of points everything is ok, labels appear in different colors.

However I could not find a way to set the key (legend) properly I would like to have a sample of the text color used for each group of points. All a get is the title associated to each group.

set term x11 
set key outside 
set grid 
set xlabel "#occurences"
set ylabel "F-score"
set title "Experiment"
plot "-" lw 1 with labels font "\"Helvetica\"" tc lt 1 title "foo" , "-" lw 1 with labels font "\"Helvetica\"" tc lt 2 title "bar"  
96.0 0.24390244 11
5547.0 0.7443704 24
3974.0 0.83244646 114
241.0 0.16025642 174
6220.0 0.7571273 188
7810.0 0.8637012 206
e

98.0 0.0 4
96.0 0.11320755 11
5547.0 0.75145125 24
3974.0 0.8333118 114
6220.0 0.7646692 188
7810.0 0.87222874 206
e

Upvotes: 3

Views: 3127

Answers (1)

Christoph
Christoph

Reputation: 48390

That is done with set key textcolor variable, as stated in the comments:

set key outside textcolor variable
set grid 
set xlabel "#occurences"
set ylabel "F-score"
set title "Experiment"
plot "-" lw 1 with labels font "\"Helvetica\"" tc lt 1 title "foo" , "-" lw 1 with labels font "\"Helvetica\"" tc lt 2 title "bar"  
96.0 0.24390244 11
5547.0 0.7443704 24
3974.0 0.83244646 114
241.0 0.16025642 174
6220.0 0.7571273 188
7810.0 0.8637012 206
e

98.0 0.0 4
96.0 0.11320755 11
5547.0 0.75145125 24
3974.0 0.8333118 114
6220.0 0.7646692 188
7810.0 0.87222874 206
e

Result with 4.6.5:

enter image description here

Upvotes: 1

Related Questions