jpc
jpc

Reputation: 139

Is it possible to make gnuplot ignore a csv row that has "N/A" instead of a number?

I am trying to make an XY scatter plot using gnuplot from a large data set, stored in a csv. After some set up (including changing the separator to a comma) I run the command plot '../foo.csv' using 4:8 with points, but nothing appears on the graph. A few of the lines have "N/A" in column 4, instead of a number. How does gnuplot handle this? Do I need to specifically tell gnuplot to ignore these lines, or should I remove them from the csv prior to using gnuplot? Could this be the reason no data shows up?

An example of data in the csv is below:

"","Car","Manufacturer","MPG","Cylinders","Displacement","Horsepower","Weight","Acceleration","Model.Year","Origin"
"5","torino","ford",17,8,302,140,3449,10.5,70,"American"
"6","galaxie 500","ford",15,8,429,198,4341,10,70,"American"
"13","torino (sw)","ford",NA,8,351,153,4034,11,70,"American"

Upvotes: 1

Views: 390

Answers (1)

Karl
Karl

Reputation: 2187

Jup, you just give the command

 set datafile missing 'NA'

However, you example dataset only has two valid points, so the autoscaling lands them on the border, where you hardly see them. plot ... w lp ps 4 to better see them.

check help set datafile missing on how gnuplot exactly handles missing and invalid datapoints (with examples), and how the behaviour can be changed.

Upvotes: 2

Related Questions