kloop
kloop

Reputation: 4721

how to improve the following gnu plot?

I have the following gnu plot:

#  automobile_input.txt
#
set term png
set output "automobile.png"
#
#  Fields in each record are separated by commas.
#
set datafile separator ","

    set title "Price versus Curb weight"
    set xlabel "Price in dollars"
    set ylabel "Curb weight in pounds"
    set grid
    plot 'x' using 1:2
    quit

x is a file containing numbers such as

   1,2
   0.5,4

etc.

I would like to make a few changes to this plot.

At the top of the plot there is "x using 1:2" and I would like to remove that.

Finally, the most important thing: I would like to add another file, y, in the same format, which will be also plotted on the same plot, only with a different sign and color (instead of pluses in red), for example, blue triangles. I would rather also the pluses be circles.

Upvotes: 4

Views: 67

Answers (1)

Gavin Portwood
Gavin Portwood

Reputation: 1217

Omit the data series title by using notitle in your plot line. Adding another curve would be done like this:

plot 'x' using 1:2 notitle, \
     'y' using 1:2 notitle

The data series points will adjust automagically. To manually specify the format, you might plot with something like this:

 plot 'x' using 1:2 with points pointtype 6 linecolor rgb 'red'  title "Data X", \
      'y' using 1:2 with points pointtype 8 linecolor rgb 'blue' title "Data Y"

You'll usually see scripts online that abbreviate these command to look like:

 plot 'x' w p pt 6 lc rgb 'red'  title "Data X", \
      'y' w p pt 8 lc rgb 'blue' title "Data Y"

Upvotes: 4

Related Questions