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
Related
I have a problem with plotting my data points with pm3d in gnuplot. In my data file, the points (2-dim domain) are not rectangular aligned, but parabolic as shown in this figure, where the data points are not aligned exactly above each other. My goal is to create a heatmap with pm3d for a specific xrange where the heatmap is continued to the borders of the selected xrange.
What I did:
Plotted the data set with pm3d using the following minimal code example:
set terminal qt
set xrange [-0.25:1.00]
set view map
splot "data.txt" u 1:2:3 with pm3d
What I got:
A heatmap of my data file, but with ugly corners at the border points at where I cut my x-domain, because the border points are not aligned "above" each other.
What I expected:
A heatmap where the "heat" values are continued to the real border of the domain as it is the case for a simple "with lines" plot, shown in this figure.
My attempts so far to achieve what I expected:
I tried several pm3d options, including the option clip1in, which only requires 1 clip of a "heat rectangle" to be inside the domain, but the result was that the corners are no laying outside of the domain, which doesn't solve the problem unfortunately.
Additional information:
OS: Ubuntu 20.04
$ gnuplot -V
gnuplot 5.2 patchlevel 8
If anybody knows how I achieve what I'm trying to do, it would be nice to share that knowledge!
Cheers!
Gnuplot 5.4 does offer this sort of smooth clipping on the z coordinate, but unfortunately that doesn't help because you want clipping on x in this case.
Here is an example of performing x clipping by manual intervention.
The complicated expression for the x coordinate is just to generate points
with a non-orthogonal grid.
xclip(x) = x > 6. ? 6. : x # clip x to maximum value of 6.
f(x,y) = sin(sqrt(x*x + y*y)) # some function to plot
set sample 21; set isosample 21
set view map
set xrange [-6 : 6]
unset key
set multiplot layout 1,2
set title "No clipping"
splot '++' using ($1+$2*$2/10.) :($2):(f($1,$2)) with pm3d
set title "Manual clipping at x=6"
splot '++' using (xclip($1+$2*$2/10.)):($2):(f($1,$2)) with pm3d
unset multiplot
I try to create a nice waterfall map with gnuplot showing the development of an optical spectrum with current. My goal is to achieve something close to this :
A waterfall plot
I have tried this command
splot [][1160:1200][-80:-30] "Waterfall.txt" u 1:2:3 w l lw 3 lc rgb 'black'
The "Waterfall.txt" file has the format suggested in the accepted answer here Gnuplot: fence plot from data.
I have ignored z-data values lower than -80, substituting them with NaN.
The outcome is shown in the next image link.
My attempt
As you can see, compared with the previous figure, this is confusing to the reader. How can I fix it in order for it to be close to the first image and thus more clear to the viewer ?
Edit:
Thanks to #Ethan's answer it worked. The outcome is shown in the figure below. The only problem is the transparency of each fence, that reveals partially the subsequent fences.
The new attempt
Assume twenty 2D files each containing Y and Z:
Gnuplot version 5.2
filename(i) = 'silver.dat'
set pm3d scansauto
set style fill solid noborder
set xyplane at 0
set log z
unset key
splot for [k=20:1:-1] filename(k) using 1:(k):2:(1.0):2 with zerrorfill \
fc "white" lc "black" lw 2
I don't have your data files so I use the same file 20 times for the purpose of illustration. It is based on the zerror demo in the gnuplot distribution and online demo set.
Note that the base of each 'fence' is set to (z=1.0) rather than zero because of the log scale on z.
The figure shown was made using a newer gnuplot. It uses partial transparency and a fancier bounding box that isn't in 5.2
After noticing the interactive gnuplot graphic upon https://lwn.net/Articles/723818/ showing country names on a mouse hover, I am wondering how to simply show the values of the points in a plot.
For example I want to hover over the "daughter bar" in https://s.natalian.org/2020-08-24/mouse-hover.svg and see 60 clearly.
However right now it just shows co-ordinates IIUC. How do I fix this?
set term svg mouse standalone
reset
$heights << EOD
dad 181
mom 170
son 100
daughter 60
EOD
unset key
set boxwidth 0.5
set style fill solid
set yrange [0:*]
plot '$heights' using 2:xtic(1) with boxes
set output '/tmp/mouse-hover.svg'
replot
You are looking for hypertext, check help hypertext.
You have to use point to anchor the hypertext.
Play with the pointsize (here ps 3) to change the area where the mouse will display the hypertext.
Since you probably don't want to display a colored point at the top of your box, make the color transparent, e.g. lc rgb 0xff123456.
Unfortunately, I haven't found (yet) anything in the gnuplot documentation how to make the font of this hypertext larger. The option font ",30" does not have any effect. If you find out please let me know. Apparently in wxt terminal you can do it (see gnuplot: Hypertext with monospace?).
Code:
### SVG standalone with hypertext
reset session
set term svg mouse standalone enhanced
set output 'tbSVGstandalone.svg'
$heights <<EOD
dad 181
mom 170
son 100
daughter 60
EOD
unset key
set boxwidth 0.5
set style fill solid
set yrange [0:*]
plot '$heights' u 2:xtic(1) w boxes,\
'' u 0:2:2 w labels hypertext point pt 7 ps 3 lc rgb 0xff123456
set output
### end of code
Result: (screenshot of SVG in Firefox. It looks like I can't place a SVG here, at least I don't know how.)
I'm trying to draw bar graphs with error bars. Here is my script,
set term pngcairo
# ... some setup code
set style data histogram
set style fill solid 1.00 border
set style histogram gap 1 errorbars lw 1
set ytics 800
set output "thttpd.png"
plot 'thttpd.dat' using 2:3:xtic(1) title col(2)
My data is like this,
File_size Original_thttpd std_dev priv std_dev
16 617.525151042 46.4794798061 623.229175781 17.4696494741
32 1094.72792871 36.709731068 1105.89255892 21.3383446583
64 1736.16701074 14.9846134633 1738.41502295 23.9069441408
......
I got figure,
As you can see, the error bars are separated from the main bar. I'm using gnuplot 5.2. Can anyone tell me how to fix this problem? Thanks!
That looks like a bug that was fixed sometime between version 5.2.2 and 5.2.4.
The program failed to recognize that use of "title col(2)" in your plot command necessarily implies the presence of an extra row of data containing column headings. You can bypass this failure by adding the command
set key autotitle columnhead
That will ensure that the program knows about the row of column header labels
even if the autotitle feature isn't used for a particular plot.
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