gnuplot crash after negative values - gnuplot

I am trying to plot data with errors e.g
-1.4 -0.2 0.4 6.1 2.5 5.2
I used plot 'data.txt' u 1:4:($1-$2):($1+$3):($4-$6):($4+$5) w xyerrorbars
After it, my plot looks ok for yerror but in xerror not. Points are in good spots but errors are shifted.
I tried to use set format xdata "%f" and so on but it doesn't work

Related

How to plot a closed polygon with a spline in gnuplot?

I tried to create a spline around a polygon with gnuplot (see picture 1). Unfortunately without success.
All "smooth " variants do not solve the problem, because most of them sort the x-values and "Bezier" is no spline.
Are there any other ideas?
Spline was created with LibreCalc
The development version of gnuplot uses a general path-following spline in 3D plots. This comes close to what you ask for, but has the limitations that
In order to trigger the path-following spline the points must not lie in a plane (the complicated third entry in the using spec below is just to move the points out of the xy plane).
You won't get rounding at the join point for the start/end of the path
This plot mode is not in a released gnuplot version
It only applies to splot, not splot
Example
unset key
set view map
splot 'spline.dat' using 1:2:($1==1?0:$0) smooth cspline with lines lt 1, \
'' using 1:2:($1==1?0:$0) with points pt 7 lt 1
18 months later
Since I see that this question is still getting views, I am adding an updated answer. The limitations mentioned in the first answer have now been removed. Gnuplot 5.5 (the development version) support a new smoothing option smooth path in both 2D and 3D plots.
Here is the documentation section:
gnuplot> help smooth path
The `smooth path` option generates cubic splines to fit points in the order
they are presented in the input data; i.e. they are not first sorted on x.
This generates a smooth spline through a closed curve or along a trajectory
that contains loops. This smoothing mode is supported for both 2D and 3D
plot commands. As always, a separate curve is created for each set
of points in the input file, where a blank line separates the sets.
Plotting `smooth path with filledcurves closed` will guarantee that each set
of points creates a closed curve. Plotting `smooth path with lines` will
generate a closed curve if the first and last points in the set overlap,
otherwise it will create an open-ended smooth path.
and here is part of a from the online collection:
$LOOP << EOD
1.5 0.5
2.5 0.5
3 1.0
3.5 1.5
4.0 3.5
3.6 4.5
3.0 2.5
4 1.5
5 1.5
EOD
plot $CURVES using 1:2 with points pt 7 ps 2 lc "steelblue" title "original points", \
'' using 1:2 smooth path with lines lt 3 title "smooth path with lines", \
$LOOP using 1:2 with points pt 7 ps 2 lc "steelblue" notitle, \
'' using 1:2 smooth path with lines lt 3 notitle

Annoying lines with style filledcurve

I am using gnuplot 5.0 patchlevel 3 and trying to plot a filledcurved generated from a data file. The data file is previously filtered and sorted with the help of awk and sort. A minimal script is
set style fill transparent solid 0.2
plot "<awk -f awkfile filename|sort -g -k 1" u 1:2 with filledcurve y1=90,'' u 1:2 w points
The output fills the curve up to y1=90, which is fine. However every data point is stick with a vertical line runnning from y to y1=90. The line is solid and non-transparent. It ruins the output. How can I get rid of them?

Gnuplot Bar Chart with Defined Upper Error and Lower Error - Horizontally Shifted? [duplicate]

Summary
I'm trying to use error bars with gnuplot but am running into two problems. The first problem is that the error bars are not correctly aligned. The second problem is that I can't specify multiple data sets when using error bars.
First problem: error bar alignment
The first problem is that the error bars are not correctly aligned as can be seen in the following image:
This image was generated from the following script:
set terminal postscript eps enhanced
set yrange [0:20]
set style data histogram
set style histogram errorbars gap 1
set output 'out.eps'
plot "test.dat" using 2:3
and the following test input data
header colA errA colB errB
typeX 10.0 1.0 15.1 1.5
typeY 5.0 0.5 12.1 0.8
The bar error bar at point 0.5 on the x-axis should be associated with first histogram entry rather than being offset. I've tried a few different things, and this simple example is very close to what is shown in the gnuplot 5.0 user manual on page 55 (screenshot below since there isn't an HTML version.
Second problem: specifying multiple data sets with error bars
Using the same test input data from before, the following code will generate a histogram plot with two data sets without using error bars:
set terminal postscript eps enhanced
set yrange [0:20]
set style data histogram
set style histogram
set output 'out.eps'
plot 'test.dat' using 2, '' using 4
But if I try to modify this, as shown below, to generate error bars I get an invalid eps file that can't be displayed.
set terminal postscript eps enhanced
set yrange [0:20]
set style data histogram
set style histogram errorbars
set output 'out2.eps'
plot 'test.dat' using 2:3, '' using 4:5
I have tested this on both OS X with gnuplot 5.0 patchlevel 2 and on Arch Linux with the same version of gnuplot and also with gnuplot 5.0 patchlevel 3
Comment out the first line (header), this solved both problems:
#header colA errA colB errB
typeX 10.0 1.0 15.1 1.5
typeY 5.0 0.5 12.1 0.8

gnuplot histogram errorbar problems

Summary
I'm trying to use error bars with gnuplot but am running into two problems. The first problem is that the error bars are not correctly aligned. The second problem is that I can't specify multiple data sets when using error bars.
First problem: error bar alignment
The first problem is that the error bars are not correctly aligned as can be seen in the following image:
This image was generated from the following script:
set terminal postscript eps enhanced
set yrange [0:20]
set style data histogram
set style histogram errorbars gap 1
set output 'out.eps'
plot "test.dat" using 2:3
and the following test input data
header colA errA colB errB
typeX 10.0 1.0 15.1 1.5
typeY 5.0 0.5 12.1 0.8
The bar error bar at point 0.5 on the x-axis should be associated with first histogram entry rather than being offset. I've tried a few different things, and this simple example is very close to what is shown in the gnuplot 5.0 user manual on page 55 (screenshot below since there isn't an HTML version.
Second problem: specifying multiple data sets with error bars
Using the same test input data from before, the following code will generate a histogram plot with two data sets without using error bars:
set terminal postscript eps enhanced
set yrange [0:20]
set style data histogram
set style histogram
set output 'out.eps'
plot 'test.dat' using 2, '' using 4
But if I try to modify this, as shown below, to generate error bars I get an invalid eps file that can't be displayed.
set terminal postscript eps enhanced
set yrange [0:20]
set style data histogram
set style histogram errorbars
set output 'out2.eps'
plot 'test.dat' using 2:3, '' using 4:5
I have tested this on both OS X with gnuplot 5.0 patchlevel 2 and on Arch Linux with the same version of gnuplot and also with gnuplot 5.0 patchlevel 3
Comment out the first line (header), this solved both problems:
#header colA errA colB errB
typeX 10.0 1.0 15.1 1.5
typeY 5.0 0.5 12.1 0.8

Is it possible to put data to plot into gnuplot's prompt?

Is it possible to put some data into gnuplot right on it's prompt?
Like this:
gnuplot> plot [ 1 2 4 8 ] with lines
Creating a .dat file, saving it, then running gnuplot, plotting, removing file... Sometimes for simple graph that seems too long. Can this be done from gnuplot's prompt?
I believe this will work for you, it should work from a control script, and may work interactively as well:
set xrange [0:5]
set yrange [0:3]
plot "-" using 1:2:3 w yerrorbars
# X Y Z
1.0 1.2 0.2
2.0 1.8 0.3
3.0 1.6 0.2
4.0 1.2 0.2
end
pause -1
This and many other excellent tips I found at this page: http://t16web.lanl.gov/Kawano/gnuplot/datafile2-e.html

Resources