0

My CSV file looks like this:

Sections,Score
text,5.80653548846
rdata,3.96936179484
data,0.378703493488
pdata,1.97732827586
rsrc,2.81352566021
reloc,0.46347168954

I'm running the command:

gnuplot -p -e "set datafile separator ','; plot '/temp_files/iMiHRlrcQLwWYXjbjmTydBITw_PlotGraph.csv' using 1:2 with lines;"

And I'm getting the error:

line 0: warning: Skipping data file with no valid points

set datafile separator ','; plot '/temp_files/iMiHRlrcQLwWYXjbjmTydBITw_PlotGraph.csv' using 1:2 with lines;
                                                                                                                                                ^
line 0: x range is invalid

I've tried the following:

  • Editing the CSV file to not contain the Sections,Score part.
  • Setting the ylabel and xlabel with set xlabel "Sections"; set ylabel "Scores";
  • Running set title "Entropy"; set grid; plot "FILENAME"; using 0:1 with lines
  • Using the suggestions from these posts: 1, 2, 3, 4

However, regardless of the research I'm still expecting gnuplot to accept the CSV file and return a plotted graph, how can I turn the CSV presented into a graph using gnuplot successfully?

An example of what I would want would be something along the lines of:

    8
    7
 S  6
 C  5
 O  4
 R  3 |\        ___
 E  2 | \      /
    1 |  \____/
    0 |  
     text rdata data
         Sections

2 Answers 2

1

As Ethan already mentioned, you need a x-coordinate. In your modified question you specify that the text in column 1 should be on the x-axis. In this case you can use the pseudocolumn 0 (which is basically the row index, starting from 0) as x-value and add the text via xticlabels(). Check help pseudocolumns and help xticlabels. For this type of plot you might want to use the plotting style with boxes or as you intended with lines.

In short, something like: plot "myData.dat" u 0:2:xtic(1) w lines, or as a full script...

Script:

### plot "text" data
reset session

$Data <<EOD
Sections,Score
text,5.80653548846
rdata,3.96936179484
data,0.378703493488
pdata,1.97732827586
rsrc,2.81352566021
reloc,0.46347168954
EOD

set datafile separator comma
set style fill solid 0.3
set boxwidth 0.8
set xtics out nomirror
set grid y
set xlabel "Sections"
set ylabel "Score"
set key noautotitle

plot $Data u 0:2:xtic(1) w boxes, \
        '' u 0:2 w linespoints pt 7
### end of script

Result:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

Column 1 of your data file contains text rather than numbers. You cannot use this column as either an x or a y coordinate. Thus both plot ... using 1:2 and plot ... using 0:1 will fail because the program finds no [x,y] coordinate pair on any line of the file. That is what the error message "no valid points" is trying to tell you.

What coordinates do you want on the x and y axes of your graph? If column 2 is y, what is x?

1 Comment

Do the edits help to better understand what I'm asking?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.