how to improve the following gnu plot? - 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"

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 choose which column put on axis like label?

I have a csv file like this:
10557,1925080,1236052,1210752,1182492
11254,3159084,2264460,2187584,2144416
11334,2348036,1540692,1504536,1458332
11456,1607704,993228,974676,960308
.....
I want create a chart with these data. I want use the first column as x-axes label, and put all other column like different line inside the chart. how can I do it?
This is my code
set terminal pngcairo enhanced font "arial,10" fontscale 2.0 size 1680, 1024
set size 1,1
set ylabel '[y]'
set xlabel '[FIRST COLUMN FROM CSV]'
set datafile separator ","
set autoscale fix
set key top left
set key box
set output 'Figure1.png'
plot \
"figure1.csv" using 2 w l linewidth 3 lc rgb "black" title "second colum", \
"figure1.csv" using 3 w l linewidth 3 lc rgb "black" title "third colum", \
"figure1.csv" using 4 w l linewidth 3 dashtype 2 title "fourth colum", \
"figure1.csv" using 5 w l linewidth 3 dashtype 5 title "fifth colum"
To get evenly spaced tics on the x-axis which get labelled with the values from the first column use xticlabels:
plot "figure.csv" using 0:2:xticlabels(1)

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

Plotting multiple plots on same page using gnuplot; trying to avoid text on the plot

I am trying to plot multiple plots on the same page of gnuplot postscript output. Although, I like the way the plots are looking, what can I do to avoid the text on the plots? (See the code below, and the plot too). If you cannnot see the text on the plot, it says: "'../binsam_Omidi.dat' using 5:($1==1?$6:1/0)"
reset
set term postscript eps color size 10,10
set output "../Results/phasespace_bins.ps"
set multiplot layout 4,5 # engage multiplot mode
set size square
set size ratio -1
plot '../binsam_Omidi.dat' using 5:($1==1?$6:1/0) w p ps 1 pt 7
set size 0.4,0.4 # set the size of the second plot in plot units
set origin 0.15,0.5 # set the origin for the second plot
plot '../binsam_Omidi.dat' using 5:($1==1?$6:1/0) w p ps 1 pt 7
unset multiplot
Thanks!
That is the legend (key) entry of the plot. You can specify your own title with the title option, like
plot x title 'my title'
If you don't specify your own title, the code of the plot command is used. This is what you see.
To have no key entry for a single plot use notitle or title ''. If you don't want to have any key at all use unset key.

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