I have a transducer data where I know I have a sudden accuracy:
My question is: How to add y-errorbars into my existing code?
set xlabel "Time [min]"
set ylabel "Temperature [Celsius]"
plot '150830AW.dat' every ::1188::1231 using 4:52 w l lc rgb 'green' title "Run 1", \
'150830AW.dat' every ::1251::1284 using 4:52 w l lc rgb 'blue' title "Run 2", \
90 title "Standard" with lines linestyle 2
and
set xlabel "Time [min]"
set ylabel "Pressure [MPa]"
plot '2015 08 30 0000 Pelletizer Feed (Wide).dat' every ::2372::2459 using 4:($8*0.006894759086775369) w l lc rgb 'green' title "Run 1", \
'2015 08 30 0000 Pelletizer Feed (Wide).dat' every ::2498::2565 using 4:($8*0.006894759086775369) w l lc rgb 'blue' title "Run 2"
Have a look at these demos: errorbars. Basically you need a third column with the error.
Since you have 0.5% accuracy on Pressure, you'll have to multiply the pressure column by 0.005 so that your using 4:52 will become using 4:52:($52*0.005).
To activate the errorbar you need to replace the w l (i.e. with lines) with with errorbars.
If you want both the line and errorbars you have to keep your line and add this new line, e.g:
plot '150830AW.dat' every ::1188::1231 using 4:52 w l lc rgb 'green' title "Run 1", \
'' every ::1188::1231 using 4:52:($52*0.005) w errorbar lc rgb 'green' notitle, \
'150830AW.dat' every ::1251::1284 using 4:52 w l lc rgb 'blue' title "Run 2", \
'' every ::1251::1284 using 4:52:($52*0.005) w errorbar lc rgb 'blue' notitle, \
90 title "Standard" with lines linestyle 2
If you want something IMHO nicer, have a look at fill between curves
Related
I two functions:
f(x) = x**2
g(x) = -(x-4)*x
I need to calculate the area between these two curves, for that I would like to have visualization. WolframAlpha has exactly what I want: https://www.wolframalpha.com/input/?i=area+between+the+curves+y%3Dx%5E2+and+y%3D-x%5E2%2B4x, however, I need to make the graphics in gnuplot. Here is my code so far:
set border linewidth 1
set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth 1
set style line 2 linecolor rgb '#dd181f' linetype 1 linewidth 1
set key at 6.1,1.3
set xlabel 'x'
set ylabel 'y'
set xrange [-0.5:3]
set yrange [0:5]
set xtics 2
set ytics 2
set tics scale 2
f(x) = x**2
g(x) = -(x-4)*x
set grid ytics lt 0 lw 1 lc rgb "#bbbbbb"
set grid xtics lt 0 lw 1 lc rgb "#bbbbbb"
plot f(x) title 'f(x)' with lines linestyle 1, \
g(x) title 'g(x)' with lines linestyle 2
It produces this output:
Is there any way I can highlight the area between these two curves like in WolframAlpha? Assuming that we know where they intersect (0 and 2), unless gnuplot can do that on its own.
If this is not something vanilla gnuplot is capable of I apologize, in that case some pointers to resources that can do that would be appreciated.
This can be achieved using filledcurves (see docs: http://gnuplot.sourceforge.net/docs_4.2/node245.html). You just need to use the below option to ensure only the area between the two curves is filled.
As an example, try this:
plot '+' using 1:(f($1)):(g($1)) title '' with filledcurves below lc rgb 'green', \
f(x) title 'f(x)' with lines linestyle 1, \
g(x) title 'g(x)' with lines linestyle 2
This is based on the way its described in the FAQ here for two curves: http://www.gnuplot.info/faq/#x1-460005.3
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)
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"
It is straightforward to label data points in Gnuplot, in this example, I use the third column as labels for this data set (data.txt):
1 -22 "Event 0"
2 -139.7 "Event 3"
3 -11 "Event 7"
4 -35.2 "Event 6"
5 -139.7 "Event 2"
6 -139.7 "Event 4"
7 -84.7 "Event 1"
8 -22 "Event 9"
9 -64.9 "Event 8"
10 -38.5 "Event 5"
gnuplot> plot 'data.txt' u 1:2, "" u 1:2:3 w labels rotate offset 1
This is the result (I omitted polishing for this purpose):
However, I need the data points plotted by cumulative sum:
gnuplot> plot 'data.txt' u 1:2 smooth cumulative
Now, how can I label the points at their new "coordinates"? Something like this does not work (I want the labels down in each knee of the cumulative curve):
gnuplot> plot 'data.txt' u 1:2 s cum, "" u 1:2:3 s cum w labels offset 1
The result should look something like this (here manually cut and positioned with Gimp):
You can plot your cumulative graph to a file, and then use those modified data as you would with a regular data file. To access the labels to can use the paste command and make use of extra columns:
set table "cumulative_labels"
plot 'data.txt' u 1:2:3 smooth cumulative w labels
set table "cumulative_data"
plot 'data.txt' u 1:2 smooth cumulative
unset table
plot 'cumulative_data' u 1:2 w l, \
"< paste cumulative_labels cumulative_data" u 4:5:3 w labels offset 1
Edit:
gnuplot-only way to do this, with no intermediate files, but dropping the smooth cumulative option:
sum = 0.
plot "data.txt" u 1:2 s cum, "" u (sum = sum + $2, $1):(sum):3 w labels offset 1
Im trying to make errorbars to a already converted value. I have value in the dat file as uk gallons per minute and have now converted it into m^3/min.
My problem is that i cannot get my error bars when i also convert the value. Initially i just bracket the converting and then the accuracy on 0.0025(0.25%) but no error bars appear..
set yrange [34:37.5]
set xlabel "Time [min]"
set ylabel "Flow [m^3/min]"
plot '2015 08 30 0000 Pelletizer Feed (Wide).dat' every ::2372::2459 using 4:($17*0.161) w l lc rgb 'green' title "Run 1", \
'' every ::2372::2459 using 4:17:(($17*0.161)*0.0025) w errorbar lc rgb 'green' notitle, \
'2015 08 30 0000 Pelletizer Feed (Wide).dat' every ::2498::2565 using 4:($17*0.161) w l lc rgb 'blue' title "Run 2", \
'' every ::2498::2565 using 4:17:(($17*0.161)*0.0025) w errorbar lc rgb 'blue' notitle, \
35.42 title "SP" with lines linestyle 2
When plotting with lines and with errorbars you are using different y-values. You have using 4:($17*0.161) for the lines, but using 4:17:(($17*0.161)*0.0025) for the errorbars, so that the errorbars are out of your yrange. Try:
set yrange [34:37.5]
set xlabel "Time (min)"
set ylabel "Flow (m^3/min)"
file = '2015 08 30 0000 Pelletizer Feed (Wide).dat'
set linetype 1 lc rgb 'green'
plot file every ::2372::2459 using 4:($17*0.161) w l lt 1 title "Run 1", \
'' every ::2372::2459 using 4:($17*0.161):(($17*0.161)*0.0025) w errorbar lt 1 notitle