gnuplot. How to not print a point at the beginning of a graph? - gnuplot

I want to have just one point of a certain shape on the whole graph. For that goal, I'm using pi property:
plot 'a.txt' every 1000 using 1:3 with linespoints pi 30 title "A",\
'b.txt' every 1000 using 1:3 with lines points pi 30 title "B",\
'c.txt' every 1000 using 1:3 with linespoints pi 30 title "C"
The problem is, gnuplot prints the first point of each of these graphs and then prints another one in the middle of the graphs. I don't want to have that first point (actually, A, B and C start from (0,0) and that makes the graph look awful).

Try to plot with lines then with points and set the first point in every clause:
plot 'a.txt' every 1000 using 1:3 with lines title "A",\
'a.txt' every 1000::2000 using 1:3 with points pi 30 notitle,\
.....

Related

Plot one single curve with different successive colors with gnuplot

Using gnuplot I would like to plot a data set, signal vs. time (let's say a chromatogram) with different colors for selected regions of the curve (let's say peaks) but I am not sure whether it is possible or not.
What I tried so far is something like:
plot [2:4.6] [0:100] 'data.csv' using 1:2 with lines lt 1,\
[4.6:4.7] [0:100] 'data.csv' using 1:2 with lines lt 2,\
[4.7:6] [0:100] 'data.csv' using 1:2 with lines lt 3
but it does not seem to work, since I only get the 'invalid expression' message.
Use linecolor variable to dynamically specify from which line type to take the color:
lt(x) = (x >= 4.7 ? 3 : (x >= 4.6 ? 2 : 1))
plot 'data.csv' using 1:2:(lt($1)) linecolor variable
Although the method proposed by Christoph answer is good for a limited number of color changes, it may be long and complicated to set up in my case since my real data set will have many peaks and many changes of color.
I found a better one based on this question gnuplot: yerrorbars with linecolor variable, it simply consists in using a third column (which can simply be added using a spreadsheet) to set the color of every data point with the gnuplot code:
plot [2:6] [0:100] 'data.csv' using 1:2:3 linecolor variable with lines notitle

Gnuplot plot error bars every 10 data points

I want to plot my data with error bars. It is to do with the syntax
plot "xyz.dat' u 1:2:3 w yerrorbars
However, since my data file has 10000 data points, plotting all error bars would make the error bars overshadow the line shape of the data. So I want to plot error bars every 10 data points. How can I do that?
Try
plot "xyz.dat" u 1:2:3 every 10 w yerrorbars
Also look at:
How do I plot every nth point

How to change dot size in gnuplot

How to change point size and shape and color in gnuplot.
plot "./points.dat" using 1:2 title with dots
I am using above command to plot graph ,but it shows very small size points.
I tried to use command
set pointsize 20
but still point size is same.
Use the pointtype and pointsize options, e.g.
plot "./points.dat" using 1:2 pt 7 ps 10
where pt 7 gives you a filled circle and ps 10 is the size.
See: Plotting data.
The pointsize command scales the size of points, but does not affect the size of dots.
In other words, plot ... with points ps 2 will generate points of twice the normal size, but for plot ... with dots ps 2 the "ps 2" part is ignored.
You could use circular points (pt 7), which look just like dots.
plot "./points.dat" using 1:2 title with dt 2 lw 4

How to add custom label to Gnuplot graph legend?

In a graph I'm making with gnuplot I draw some grey lines (set arrow command), which represent the physical boundaries of my experiment (i.e., walls)
I would like to know how I can add this information on the legend of the graph, so it says "Walls" and have a grey line next to it.
I thought about creating a new series that contained this information, but I was wondering if it's possible to explicitly add it.
You can't add information directly to the legend. You can, however, either draw the legend explicitly, or plot a line which will not appear within the range of the plot, e.g.
plot [][0:1] 2 lc rgb 'gray' t 'Walls'
Or, if your x and y limits are already set:
...
[set x and y limits here]
...
plot 1e20 lc rgb 'gray' t 'Walls'
Just wanted to note: since plotting a single line tended to mess up a graph of mine, a better solution for me was to plot a single point; but as found in Plotting single points « Gnuplotting, that is kinda difficult (especially if insertion at arbitrary plot legend/key position is needed) - unless redirection is used... This is what worked for me:
plot "filename" using 1:8 \
,\
... # more plot lines here
,\
"<echo '-1 -1'" lc rgb 'white' with points title '---' \
,\
... # more plot lines here
One simple way is to make the name of the data file the legend which you want and then plot that data file.

How to treat the first line of the data file as column labels in gnuplot?

I have a table like this:
A B C D E F G H I
10 23998 16755 27656 17659 19708 20328 19377 18925
20 37298 33368 53936 41421 44548 40756 40985 37294
I use this command to plot
plot "C:/file.txt" using 1:2 with lines smooth bezier, "C:/file.txt" using 1:3 with lines smooth bezier, ...
However, all the labels come out as the file name. Is it possible for gnuplot to read the first row and label the lines accordingly?
set key autotitle columnhead
plot for [n=2:12] 'vv.csv' u 1:(column(n)) w lines title columnhead(n)
n starts from 2 to skip the header.
I checked the documentation and I don't see a way to do it automatically, but you can manually set a title with
plot "file.txt" using 1:2 title "A" with lines smooth bezier ...
I once wrote a script to plot FM radio station frequencies along an axis from 87MHz to 108MHz, using the names of each radio station as vertical labels. This was not a pure gnuplot solution, the input file is processed with perl with make, but I suggest you have a look at it and see if you can use something like that.
You could also use a gnuplot toolkit such as this one for Python if you want have a lot of data to plot and you want to automate the extraction of the titles.

Resources