0

I am going to plot a file containing 4 columns. first and second column are x and y respectively. I want to categorize these point based on the third and fourth column. In fact, the third column should display the color (red or blue) of point and the fourth column should determine its type (square or circle ). how could I reach to this goal by gnu-plot? I should mention that I tried this, by it does not work!

set style line 1  lc rgb 'red' pt 7
set style line 2  lc rgb 'red' pt 7
set style line 3  lc rgb 'blue' pt 9
set style line 4  lc rgb 'blue' pt 9
plot 'data' w ($3= 1 && $4= 1) ? p ls 1 \
            : ($3= 1 && $4= 2) ? p ls 2 \
            : ($3= 2 && $4= 1) ? p ls 3 \    
            : ($3= 2 && $4= 2) ? p ls 4

1 Answers1

1

Please check help points. From the manual:

plot DATA using x:y:pointsize:pointtype:color \
        with points lc variable pt variable ps variable

You don't show sample data. If you can adjust your data, the easiest would be the following below. If you want to set the color by name in your file, check this.

Code:

### variable pointtype and color
reset session

$Data <<EOD
1 2 5 0xff0000
3 4 7 0xff0000
5 6 5 0x0000ff
7 8 7 0x0000ff
EOD

plot $Data u 1:2:3:4 w p ps 5 pt var lc rgb var
### end of code

Result:

enter image description here

theozh
  • 22,244
  • 5
  • 28
  • 72