Gnuplot error bars values below 1 doesn't appear - gnuplot

I have those data:
Length A B C D E F A_err B_err C_err D_err E_err F_err
17 0,51 1,4 0 0 0 0,07 0,11 0,33 0 0 0 0,08
18 1,33 2,49 1,88 0,51 1,21 0,2 0,18 0,43 1,05 0,5 0,5 0,14
19 2,56 3,83 3,75 0,76 4,22 0,81 0,25 0,53 1,47 0,61 0,92 0,28
20 8,28 7,22 3,44 5,46 5,16 9,19 0,44 0,72 1,41 1,59 1,02 0,89
21 29,96 20 15,78 16,65 13,66 62,58 0,74 1,11 2,82 2,6 1,58 1,49
22 34,16 42,3 56,25 31,51 37,14 16 0,76 1,37 3,84 3,25 2,22 1,13
23 14,23 16,59 17,03 29,86 21,28 1,55 0,56 1,03 2,91 3,2 1,88 0,38
24 6,98 4,39 1,72 12,58 9,6 9,54 0,41 0,57 1,01 2,32 1,35 0,9
25 1,23 1,02 0,16 1,65 4,55 0,05 0,18 0,28 0,31 0,89 0,96 0,07
26 0,45 0,44 0 0,89 1,76 0 0,11 0,18 0 0,66 0,6 0
27 0,18 0,1 0 0 1,04 0 0,07 0,09 0 0 0,47 0
With this code, I obtain a nice histogram with error bars:
set terminal pngcairo enhanced font "arial,15" fontscale 2.0 size 1600,900
set output 'length.png'
set style fill solid 0.7 border lt -1
set key inside right top vertical Right noreverse noenhanced autotitles columnhead nobox
set grid ytics
set nokey
set style histogram errorbars linewidth 1 gap 3 title offset character 0, 0, 0
set datafile missing '-'
set style data histograms
set xtics border in scale 1,0.5 nomirror offset character 0, 0, 0 autojustify
set xtics norangelimit font ",12"
set xtics ()
set xlabel "n"
set ylabel "Percentage (%)"
set title "length"
set bars 0.3 front
set datafile separator "\t"
set yrange [ 0 : * ] noreverse nowriteback
plot 'length.dat' using 2:8:xtic(1), '' u 3:9:xtic(1), '' u 4:10:xtic(1), '' u 5:11:xtic(1), '' u 6:12:xtic(1), '' u 7:13:xtic(1)
The obtained image is here: http://i.stack.imgur.com/s88QJ.png
But, some error bars just not appear. I notice that is because the error value is below 1. But why ? I'd like all error bars appearing. Is there a problem in the code that forbid errors below 1 to appear ?
Thanks for your help

To me, it looks like your problem is that you're using , as a decimal point character in your file instead of . that gnuplot understands natively. There are two possible solutions. The first I found from googling, but can't test:
set locale
or
set locale "ja_JP.UTF-8" #gnuplot complains this isn't available for me ...
or perhaps set decimalsign local "..."
The second solution is a little less elegant, but it involves converting all of your , to . in your datafile. That's a trivial thing to do using sed:
sed -e 's/,/\./g' length.dat > length2.dat
Now you can just plot using length2.dat and it should work OK (it did for me). As an aside, I think that's quite a nicely colorful plot. The pngcairo terminal does a good job with it.

Related

How do I limit a gnuplot polar to a 180 degree range for Gnuplot 5.2?

I am creating a seemingly duplicate question posted by Matt in 2015, however, the answer posted by Christoph doesn't work at the moment for me, since I'm using Gnuplot 5.2.
When I use Matt's input date and Christoph's script, I end up with this result:
Picture here
As can be seen, the bottom half (3rd & 4th quadrant) of the plot is plotted, yet it should not be.
reset
set terminal pngcairo font ',10'
set polar
set angle degrees
set size ratio 1
set lmargin 8
set style line 11 lc rgb 'gray80' lt -1
set grid polar ls 11
unset border
unset tics
set xrange [-1:1]
set yrange [0:1]
set size ratio -1
r = 1
set rtics 0.166 format '' scale 0
set label '0°' center at first 0, first r*1.05
set label '-90°' right at first -r*1.05, 0
set label '+90°' left at first r*1.05, 0
set for [i=1:5] label at first r*0.02, first r*((i/6.0) + 0.03) sprintf("%d dB", -30+(i*5))
unset raxis
set key outside top right
set output 'polar.png'
plot 'norm_polar_1000.txt' w lp ls 1 t '1k'
Data:
180 0.657067
172.5 0.6832
165 0.717767
157.5 0.7461
150 0.7747
142.5 0.806167
135 0.835633
127.5 0.865167
120 0.890533
112.5 0.918133
105 0.929633
97.5 0.9566
90 0.9632
82.5 0.9566
75 0.929633
67.5 0.918133
60 0.890533
52.5 0.865167
45 0.835633
37.5 0.806167
30 0.7747
22.5 0.7461
15 0.717767
7.5 0.6832
0 0.657067
To get to my own problem, I would like to get a very similar plot but with only 2nd and 3rd quadrant instead.
My code:
reset
set terminal pngcairo font ',12'
set polar
set angle degrees
set size ratio -1
set tmargin 3
set bmargin 3
set style line 11 lc rgb 'gray80' lt -1
set grid polar ls 11
unset border
unset tics
unset key
r=1
set rrange [0:r]
set xrange [-1:0]
set yrange [-1:1]
rOffset = 1.1
set rtics 0.166 format '' scale 0
set label '0°' center at first 0, first r*rOffset
set label '90°' right at first -r*rOffset, 0
set label '180°' center at first 0, first -r*rOffset
set output 'TestPolar.png'
plot 'exampleData.txt' u ($1+90):2
exampleData.txt:
10 0.1
30 0.2
50 0.3
70 0.4
90 0.5
110 0.6
130 0.7
150 0.8
170 0.9
Current resulting picture here
Any ideas?
It looks to me that gnuplot's trange in 5.2 is always in radians rather than degrees, even if the data itself is in degrees. That seems like a bug but you can work around it.
In 5.2 do not set xrange or yrange to limit data in polar mode; use rrange and trange. xrange and yrange affect the entire plot layout, not just the data.
Also note that you can move the origin on theta to the top using command set theta top. If you do this you need not add 90° to each data point.
Assuming that by "only the 2nd and 3rd quadrant" you mean 90 < theta < 270, your script becomes
set polar
set angle degrees
set size ratio -1
set tmargin 3
set bmargin 3
set style line 11 lc rgb 'gray80' lt -1
set grid polar ls 11
unset border
unset tics
unset key
r=1
set rrange [0:r]
set trange [ pi/2 : 3*pi/2 ]
set theta top
set rtics 0.166 format '' scale 0
set ttics (0,90,180) format "%g°"
plot 'exampleData.txt' using ($1):2 with lines
Note that I set trange in radians rather than degrees to work around the bug.
Output using gnuplot 5.2.4 is attached

histogram with errorbars, pb with the titles of the columns

these are my data : TABLE11-mol+func.dat
#mol PBE optPBE optB86b BEEF Exp IncertitudeBEEF 0
0 PBE-PBE optPBE-vdW1 optB86b-vdW1 BEEF-vdW2 Exp Incert.BEEF 0
1 0.014 0.226 0.210 0.125 0.155 0.10444 0
2 0.033 0.362 0.392 0.223 0 0.16794 0
3 1.742 1.755 2.152 1.432 1.36 0.29116 0
4 1.206 1.441 1.724 1.115 0 0.17857 0
5 0.934 1.533 1.857 1.063 0 0.30034 0
6 0.777 1.514 1.843 0.959 1.295 0.31264 0
7 2.018 2.298 2.858 1.751 0 0.37737 0
8 1.084 1.648 2.336 1.033 1.762 0.60643 0
9 1.504 2.355 3.451 1.449 2.694 1.0138 0
this is my code :
set key left
set auto x
set ylabel "- E_{ads} (eV)" font "Times-Roman, 18"
set yrange [0:3.5]
set ytics (0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5) font "Times-Roman, 18"
set style data histograms
set style histogram errorbars lw 1
set style fill solid border -1
set boxwidth 0.9
set xtics ("Methane" 0, "Ethane" 1, "Ethylidyne" 2, "Ethylene" 3, "Butene" 4, "Cyclohexene" 5, "Butadiene" 6, "Benzene" 7, "Naphtalene" 8) font "Times-Roman, 15"
set xtic nomirror rotate by -45 scale 0
set grid y
plot 'TABLE11-mol+func.dat' using 2:8 ti col, '' u 3:8 ti col, '' u 4:8 ti col, '' u 5:7 ti col, '' u 6:8 ti col
this gives an histogram with wrong title for each color
so I tried to add them "with my hands" with this line instead of the last one :
plot 'TABLE11-mol+func.dat' using 2:8 ti 'PBE', '' u 3:8 ti 'optPBE', '' u 4:8 ti 'optB86b', '' u 5:7 ti 'BEEF', '' u 6:8 ti 'Exp'
and this messes up my histogram, with weird stuffs who appear all over the diagram, and it adds an xtic and bars...
somebody could help me ?
it's even more weird because it use to work some month ago... maybe it's because I have a new version of gnuplot ?
Gnuplot fails to select the correct column to get the title from. It tries to always use the 8th column, as given by the second column in the using option, although this gives the error estimate and not the y-value. You must explicitely give the column number as e.g. ti col(3):
set key left
set yrange [0:3.5]
set ytics 0.5
set style data histograms
set style histogram errorbars lw 1
set style fill solid border -1
set boxwidth 0.9
set xtics ("Methane" 0, "Ethane" 1, "Ethylidyne" 2, "Ethylene" 3, "Butene" 4, "Cyclohexene" 5, "Butadiene" 6, "Benzene" 7, "Naphtalene" 8)
set xtic nomirror rotate by -45 scale 0
set grid y
plot 'TABLE11-mol+func.dat' u 2:8 t col(2), '' u 3:8 t col(3), '' u 4:8 t col(4), '' u 5:7 t col(5), '' u 6:8 t col(6)

Gnuplot: how to write the z values in a heatmap plot

I am using Gnuplot 4.6.5
I want to write the z value in a heatmap plot.
Here is the code for producing the heatmap:
#
# Two ways of generating a 2D heat map from ascii data
#
set title "Heat Map generated from a file containing Z values only"
unset key
set tic scale 0
# Color runs from white to green
set palette rgbformula -7,2,-7
set cbrange [0:5]
set cblabel "Score"
unset cbtics
set xrange [-0.5:1.5]
set yrange [-0.5:1.5]
set view map
plot '-' using 1:2:3 with image
0 0 5
0 1 4
1 0 2
1 1 2
e
This gives:
I want to write the z values in the figure:
My actually data is much larger than the demonstration data used here. So it is almost impractical to write each point manually.
Any help would be appreciated.
You can use the labels plotting style for this. See also gnuplot matrix or plot : display both color and point value for a very similar question:
unset key
set palette rgbformula -7,2,-7
set cbrange [0:5]
set cblabel "Score"
unset cbtics
set autoscale fix
plot '-' using 1:2:3 with image, \
'-' using 1:2:(strcol(3)) with labels
0 0 5
0 1 4
1 0 2
1 1 2
e
0 0 5
0 1 4
1 0 2
1 1 2
e

Show Y Label in groups with Gnuplot

I have this points:
0.00049 1.509
0.00098 1.510
0.00195 1.511
0.00293 1.509
0.00391 1.510
0.00586 1.523
0.00781 1.512
0.01172 1.514
0.01562 1.510
0.02344 1.511
0.03125 1.510
0.04688 7.053
0.06250 7.054
0.09375 7.187
0.125 7.184
0.1875 7.177
0.25 7.207
0.375 16.588
0.5 24.930
0.75 39.394
1 56.615
1.5 77.308
2 84.909
3 89.056
4 88.485
6 88.678
8 89.022
12 88.513
16 88.369
24 88.512
32 88.536
48 87.792
64 87.716
96 87.589
128 87.608
192 87.457
256 87.388
And this gnuplot script:
#! /usr/bin/gnuplot
set terminal png
set output "lat_mem_rd.png"
set title "Memory Latency Benchmark (Stride 512)"
set xlabel "Memory Depth (MB)"
set ylabel "Latency (ns)"
set xtics rotate by 45 offset 0,-1
set xtics font "Times-Roman, 8"
set grid
set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 ps 1 # --- blue
plot "lat_mem_rd.dat" using (log($1)):2:xtic(1) smooth unique title "" with linespoints ls 1
which generates this graphic:
But i want to show the y values in the y label with one of the approximated values in those approximations, for example, for all of the values with x values between 3 and 256, the y label is set to just one, maybe 88.513 that corresponds to x=12 or other (or maybe the average of those points if its not very difficult)...
The same for x values between 0 and 0.02344 and for x values between 0.03125 and 0.1875.
This y values will substitute the values 10, 20, ..., 90.
Here is a modification of your script that might do what you want, if I understand you correctly:
set title "Memory Latency Benchmark (Stride 512)"
set xlabel "Memory Depth (MB)"
set ylabel "Latency (ns)"
set xtics rotate by 45 offset 0,-1
set xtics font "Times-Roman, 8"
set grid
a = ""; p = 0; nn = 1; nt = 37; d = 4; s = 0
f(x) = (x>p+d || nn >= nt)?(nn=nn+1, p=x, a=a." ".sprintf("%5.2f", s/n), n=1, s=x):(nn=nn+1, p=x, s=s+x, n=n+1)
plot "lat_mem_rd.dat" using 1:(f($2)) # Just to set array "a"
set ytics 0,0,0
set yrange [0:90]
set for [aa in a] ytics add (aa aa)
set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 ps 1 # --- blue
set terminal png
set output "lat_mem_rd.png"
plot "lat_mem_rd.dat" using (log($1)):2:xtic(1) smooth unique title "" with linespoints ls 1
This script produces this plot:
The strategy is to accumulate a sum of Y-values and calculate an average every time the Y-value increases by at least an amount d; these averages are stored in a string variable "a", which is looped over to set the ytic values before the final plot command. This way clusters of closely-spaced Y-values give rise to a ytic at their average value; I think that was what you wanted.

Plotting a histogram, wrong alignment of bars and labelling

I'm having trouble with a gnuplot, somehow the x labelling shifts to the right (or the bars to the left) when defining
set style data histograms
The Plotscript:
set boxwidth 0.9 absolute
set style fill solid 1.00 border lt -1
set key inside left top vertical Right noreverse noenhanced autotitles nobox
set style histogram clustered gap 5 title offset character 0, 0, 0
set datafile missing '-'
set style data histograms
set xtics border in scale 0,0 nomirror rotate by -45 offset character 0, 0, 0
set xtics norangelimit font ",8"
set xlabel "Scaling Factor"
set ylabel "Execution time [ms]"
set title "Database performance db4o vs Sqlite - Testcase 1 [indexed]"
set logscale y
set terminal pdf
set output 'db4o_vs_sqlite_indexed.pdf'
plot 'db4o_sb1-5idx.dat' using 3:xtic(1) title 'db4o', 'sqlite_sb1-5idx.dat' using 3 title 'Sqlite'
The data:
"Scaling Factor" "Testcase 1" "Testcase 2" "Testcase 3" "Testcase 4"
1 0 34 28 11
2 1 136 91 65
3 0 297 198 101
4 0 487 297 214
10 0 3124 1896 1567
20 0 13000 7907 7628

Resources