Gnuplot gives me the following picture with an odd disjoint in the second graph, whose origin I cannot determine. I've included the data below, in which the x-values are monotonically increasing, which should rule out the possibility of such a disjoint. Any help appreciated!
Generated from the following script:
set size 0.8,0.4
set lmargin 1
set terminal png
set output "test.png"
set multiplot
set origin 0.1,0.1
set xtics 5
set xrange[0:25]
set xlabel "Year"
plot "./g1" u ($1+1):2 w lines t "4 years"
set xlabel ""
set origin 0.1,0.5
set xtics format ""
set x2tics 5
plot "./g2" u ($1+1):2 w lines t "5 years"
unset multiplot
Data for g1 is:
0.000000 1.000000
1.000000 3.000000
2.000000 9.000000
3.000000 27.000000
4.000000 0.809131
5.000000 2.427394
6.000000 7.282183
7.000000 21.846549
8.000000 0.654694
9.000000 1.964081
10.000000 5.892243
11.000000 8.935199
12.000000 0.529733
13.000000 1.589200
14.000000 3.983240
15.000000 2.509780
16.000000 0.428624
17.000000 1.233139
18.000000 1.951804
19.000000 0.595792
20.000000 0.343980
21.000000 0.809600
22.000000 0.729229
23.000000 0.171423
24.000000 0.258384
25.000000 0.426250
Data for g2 is:
0.000000 1.000000
1.000000 3.000000
2.000000 9.000000
3.000000 27.000000
4.000000 81.000000
5.000000 2.427394
6.000000 7.282183
7.000000 21.846549
8.000000 65.539647
9.000000 196.618942
10.000000 5.892243
11.000000 17.676730
12.000000 53.030190
13.000000 159.090569
14.000000 241.250367
15.000000 14.302798
16.000000 42.908394
17.000000 128.725182
18.000000 322.642448
19.000000 203.292210
20.000000 34.718531
21.000000 104.155593
22.000000 299.652772
23.000000 474.288428
24.000000 144.777335
25.000000 84.275565
That's strange. On my system (ubuntu 11.10 64bit) I don't see the problem you have:
$ gnuplot --version
gnuplot 4.4 patchlevel 3
$ gnuplot < a.gnuplot # a.gnuplot is your script, unmodified
And it produces this:
If I were you I'd check:
gnuplot version
The input files - in vim use set list to see if there's any rampant characters hidden
Related
I've a set of data in three columns:
1st column: order criterion between 0 and 1
2nd: x vals
3rd: y vals
As a data file example:
0.027 -29.3 -29.6
0.071 -26.0 -31.0
0.202 -14.0 -32.8
0.304 -3.4 -29.3
0.329 -0.5 -26.0
0.409 6.7 -14.0
0.458 11.7 -3.4
0.471 12.8 -0.5
0.495 12.5 6.7
0.588 18.8 11.7
0.600 20.4 12.8
0.618 20.8 12.5
0.674 20.9 18.8
0.754 22.1 20.4
0.810 27.0 20.8
0.874 24.7 20.9
0.892 9.4 22.1
0.911 -11.5 27.0
0.943 -23.7 24.7
0.962 -29.6 9.4
0.991 -31.0 -11.5
0.999 -32.8 -23.7
My goal is to plot (x,y) points and a trend curve passing through each points ordered in ascending order with the first column values.
I use the following script:
set terminal png small size 600,450
set output "my_data_mcsplines_joined_points.png"
set table "table_interpolation.dat"
plot 'my_data.dat' using 2:3 smooth mcsplines
unset table
plot 'my_data.dat' using 2:3:(sprintf("%'.3f", $1)) with labels point pt 7 offset char 1,1 notitle ,\
"table_interpolation.dat" with lines notitle
Here mcspline results as an example:
mcspline joined points figure
The resulting curve should have the shape of a spindle or a loop.
Whatever smooth options used, Gnuplot seems invalid to handle such aim.
Unfortunatly most of smooth (mcspline, csplines...) options do a monotonic ordering of data.
How can I plot a trend curve passing through each points ordered in ascending order with the first column values?
Thanks.
I cannot post an image in a comment, and so place it here. I don't think a 2D plot will be sufficient, based on this 3D acatterplot of the data in your question.
I am trying to make a chart of data, which depends on time. I have this data:
01/1851 NaN 0.812 0.862 0.735 2.19
02/1851 NaN 1.739 1.733 1.695 1.875
03/1851 NaN 1.472 1.376 1.458 3.31
04/1851 NaN 1.847 1.775 1.828 6.06
05/1851 4.48 2.038 1.762 2.125 7.695
06/1851 10.06 0.347 0.276 0.383 5.48
07/1851 6.67 0.402 0.323 0.395 9.76
08/1851 3.21 1.57 1.469 1.421 8.62
09/1851 1.78 2.64 2.616 2.589 10.075
10/1851 3.7 1.269 1.314 1.137 4.295
11/1851 7.62 6.206 6.236 6.058 8.87
I need to make a chart of all this columns in one chart. Problem is, that date is monthly, and some values are NaN (not a number) which should not be ploted, but it says "all points y value undefined!" when i do this
set xdata time
gnuplot> set timefmt "%m/%y"
gnuplot> set xrange ["01/1851":"12/2014"]
gnuplot> set format x "%m/%y"
gnuplot> set timefmt "%m/%y"
gnuplot> plot "milesovka.txt" u 2:3
Can somebody help me? I tried this even ix excel, but i doesn't take dates before 1900.
Why do you specify u 2:3? You then wouldn't have a date on the x-axis.
This seems to work fine:
set xdata time
set timefmt "%m/%Y"
set format x "%m/%Y"
plot for [i=2:6] "milesovka.txt" u 1:i ti "Column ".i w lp
Given dataset:
0 t1 0.52
1 t2 0.66
2 t3 0.58
3 t4 0.57
4 t5 0.68
5 t6 0.61
6 t7 0.55
7 t8 0.52
8 t9 0.58
9 t10 0.50
10 t11 0.59
I cannot manage to get the colors of the bars to change. What I'm trying below is to color green the highest score which happens on line 4. Please have a look over the below:
set terminal postscript eps enhanced 20
set output "edscore2_joint.eps"
set style line 1 lc rgb "#5F9EA0"
set style line 2 lc rgb "#DC143C"
set style line 3 lc rgb "green"
set yrange [0:1]
set ylabel "ed_{score}"
set xlabel "Technique"
set style fill solid
set boxwidth 0.5
set xtics rotate by -45
plot "edscore2_joint.dat" using 1:3:xtic(2) with boxes ls 1 fillstyle pattern 1 notitle ,\
"edscore2_joint.dat" every ::4::4 using 1:3:xtic(2) with boxes ls 3 fillstyle pattern 2 notitle ,\
"edscore2_joint.dat" using 1:($3+0.05):3 with labels notitle
The terminal postscript is monochrome by default. Use either the option color, or, if you have a recent enough gnuplot version, use the terminal epscairo.
I am trying to plot some data with Gnuplot and would like to use a logscale on the x axis. This does not work, Gnuplot gives the error "x range must be greater than 0 for log scale". I saw examples that used a logscale with negative values on the y axis and tried to do it similar for the x axis, but it seems I can not get it to work. Initially I thought it would be the zero values, but even when I remove them, it does not work.
This is a little example:
stats 'stat_data1'
num1=STATS_records
stats 'stat_data2'
num2=STATS_records
set terminal pdf
set output "Cumulative_noise.pdf"
set autoscale yfix
set autoscale xfix
set key bottom right
set xlabel 'Noise in dB'
set ylabel 'Percent'
set xrange [0:110] reverse
set logscale x
set style increment user
set style line 2 lc rgb '#FF0000' lt 1 pt 1 ps 1
set style line 3 lc rgb '#008000' lt 2 pt 2 ps 2
set style line 4 lc rgb '#0000FF' lt 3 pt 3 ps 3
plot 0/0 notitle,\
'stat_data1' u (-$3) : ((100.0/num1)) title 'Node 1' smooth cumulative,\
'stat_data2' u (-$3) : ((100.0/num2)) title 'Node 2' smooth cumulative
And here some data. First file:
1437818411 -54 -95 85.2 0.0
1437818425 -54 -95 78.0 0.0
1437818440 -71 -95 38.7 0.0
1437818456 -70 -95 51.7 0.0
1437818471 -71 -95 42.0 0.0
Second file:
1437818545 -50 -95 43.7 100.0
1437818561 -51 -95 52.0 100.0
1437818576 -50 -94 79.4 0.10744142234781584
1437818592 -51 -94 16.6 0.308927509416507
1437818605 -49 -95 85.2 0.04368438558438699
I hope somebody has an idea as this would be very convenient. Thank you in advance!
The numbers given in the xrange settings are also subject to the actual axis transformations.
Removing the set xrange [0:110] fixes the error.
I am a big fan of Gnuplot and now I would like to use the fit-function for time series.
My data set is like:
1.000000 1.000000 0.999795 0.000000 0.000000 0.421927 0.654222 -25.127700 1.000000 1994-08-12
1.000000 2.000000 0.046723 -0.227587 -0.689491 0.328387 1.000000 0.000000 1.000000 1994-08-12
2.000000 1.000000 0.945762 0.000000 0.000000 0.400038 0.582360 -8.624480 1.000000 1995-04-19
2.000000 2.000000 0.060228 -0.056367 -0.680224 0.551019 1.000000 0.000000 1.000000 1995-04-19
3.000000 1.000000 1.016430 0.000000 0.000000 0.574478 0.489638 -3.286880 1.000000 1995-07-15
And my fitting script:
set timefmt "%Y-%m-%d"
set xdata time
set format x "%Y-%m-%d"
f(x)=a+b*x
fit f(x) "model_fit.dat" u 10:($2==2?$4:1/0) via a,b
So I make a conditional fitting to time data.
My problem is, that the Gnuplot fit function doesn't work on time data.
I found a similar question here: Linear regression for time series with Gnuplot but I don't want to use other software. And I also don't know how to change time values to numbers, and then back again....
Can anyone help me solving this with Gnuplot?
Thanks a lot!
Indeed, gnuplot's fitting mechanism works fine for time-data. You must only pay attention to some details.
In general, a linear fit through two data points can be solved exactly. But gnuplot does generally a nonlinear fit, so the initial values are important.
The effective x-value used for the line is given in seconds. Using an initial value of b = 1e-8 works fine here:
set timefmt "%Y-%m-%d"
set xdata time
set format x "%Y-%m-%d"
f(x)=a+b*x
a = 1
b = 1e-8
fit f(x) "model_fit.dat" u 10:($2==2?$4:1/0) via a,b
plot "model_fit.dat" u 10:($2==2?$4:1/0) lt 1 pt 7 title 'data',\
f(x) w l lt 1 title 'fit'