gnuplot - linecolour: do not wrap around - plot

UPDATE
So apparently, the order of options does matter. Wasn't aware of that. Still,
rowi=1
rowf=7
colour=0
plot for [i=0:rowf-rowi+3] filename.'.csv' u ($0+i):2:3:(colour=colour+1):xtic(1) every ::i+1::i+1 w errorbars pt 7 lc var notitle
will start re-using colour after the eight entry where I want a different colour for each of the 10 points plotted.
How do I do that?

In gnuplot, the lc (linecolor) and pt (pointtype) parameters belong to the w (with) clause (see help plot with), so putting notitle between pt 7 and lc var doesn't work. If you move the notitle clause to the end of the plot command line, this will fix the error you are getting. Like this:
plot for [i=0:rowf-rowi+3] filename.'.csv' u ($0+i):2:3:xtic(1) every ::i+1::i+1 w errorbars pt 7 lc var notitle
Without lc var, by default the colours will eventually repeat but you can set the palette to anything you like. See: Gnuplot repeats colors in rowstack histograms

Related

Gnuplot: how to plot single points with custom xlabels

my problem is the following, I have a text file like that:
#X,#Y
1,1.00182349
2,4.024570000000001
3,8.73499
What I want to get is a plot like that:
where, basically, each y value is plotted as distinct point and on the x-axis my label are N,L,H.
I made that picture with the plot command in octave, but I'm forced to do that with gnuplot.
Please, can someone tell me how to do that?
Thanks.
You can specify arbitrary label for the tic labels:
set datafile separator comma
set logscale y
set xtics ("N" 1, "L" 2, "H" 3)
plot "test.dat" using 1:2:1 notitle with points linecolor variable pointtype 5 pointsize 2

How to manipulate with the data in a cycle gnuplot 4.6

I would like to plot several lines in a gnuplot (version 4.6 or 5.0) using loop and during plotting manipulate with the data.
For simple plotting of the data (without manipulation) i use
plot for [i=2:100] 'data.dat' u 1:i with lines lt 1 lc rgb 'blue' notitle
and everything is fine: Normal result
but!
when i'm trying to manipulate with data in this code:
plot for [i=2:100] 'data.dat' u 1:(i-0.3) with lines lt 1 lc rgb 'blue'
the gnuplot resist to my manipulation and gives the strange result:
The strange result after the second code and assumptions to manipulate on the date. Also I've tried ($i-0.3) instead of (i-0.3) and also without brackets, all this doesn't work. Could anyone help?
Thanks in advance.
Use column(i) to access a column's value for calculation, if the column number is given by a variable i:
plot for [i=2:100] 'data.dat' u 1:(column(i)-0.3)

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.
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"

filling under step functions in gnuplot

I am using Gnuplot to draw step functions from an input file:
plot 'myFile' using 1:2 with steps
I want to fill underneath the plot. something like
plot 'myFile' using 1:2 with filledcurves
But Gnuplot fill underneath the diagram by drawing a line between consecutive points.
How can I fill in underneath the step function?
Use the fillsteps plotting style, which is the same as steps, but the area between the curve and y=0 is filled:
set samples 11
set xrange [0:10]
plot '+' with fillsteps fs solid 0.3 noborder lt 1,\
'+' with steps lt 1 lw 4

How to use the same key and same colours for different datasets with gnuplot

I am plotting:
p " file1" u ($2-0.25):8:(.2) every ::1::568, "file2" u ($2):8:(.2) every ::568::1136, "file3" u ($2+0.25):8:(.2) every ::1137::1705
It produces three different keys and three different colour lines. However, I would also like to have the three of them using the same colour and the same legend (key). Is that possible?
You can specify title and linecolor (or fill) for each datafile. To remove the legend entry, use notitle.
plot sin(x), cos(x) linecolor 1 notitle

Resources