gnuplot: How to create colored grid regions, not just colored grid lines? - colors

I am using "gnuplot 5.2 patchlevel 2". I am trying to create background grid colored-columns or colored-areas like the picture below. So far, I am only able to color the grid-lines. But I want to color the grid areas. What is the best way? Here is my code:
set terminal svg
set output 'out.svg'
set key off
set xlabel 'X'
set ylabel 'Y'
set title 'Data'
set grid
set grid xtics lw 0.25 lc rgb "#ff0000" # line only, but I want to color the whole area
#unset grid
#set grid ytics lt 0 lw 1 lc rgb "#0000ff"
set xrange [0:4]
set yrange [0:100]
set tics scale 0.5
set xtics nomirror
set ytics nomirror
set style fill solid noborder
set linetype 1 lc rgb 'red' lw 0.35
set linetype 2 lc rgb '#009900'
set linetype 3 lc rgb 'black' lw 0.5
set boxwidth 0.5 relative
set style fill solid border lc rgb "black"
plot "data.txt" using 1:2:4:3:5:($5 < $2 ? 1 : 2) linecolor variable with candlesticks, \
"data.txt" using 1:6 with lines lt 3, \
"data.txt" using 1:5:7 with filledcurves fs transparent solid 0.3 lc rgb "blue"
And here is my sample data.txt file for the plotting:
1 10 30 5 20 23 29
2 25 45 10 30 34 37
3 30 50 20 25 47 53

You could use a dummy function like [x=0:16:1] '+' us (x/2):(100/(int(x)%4!=1)) with filledcurves x1.
Every fourth point generates a NaN and interrupts the curve.
$data <<EOD
1 10 30 5 20 23 29
2 25 45 10 30 34 37
3 30 50 20 25 47 53
5 10 30 5 20 23 29
7 25 45 10 30 34 37
8 30 50 20 25 47 53
EOD
set style fill solid noborder
set linetype 1 lc rgb 'red' lw 0.35
set linetype 2 lc rgb '#009900'
set linetype 3 lc rgb 'black' lw 0.5
set boxwidth 0.5 relative
set style fill solid border lc rgb "black"
plot sample [x=0:16:1] '+' us (x/2):(100/(int(x)%4!=1)) with filledcurves x1 fc rgb "#EEEEEE",\
$data using 1:2:4:3:5:($5 < $2 ? 1 : 2) linecolor variable with candlesticks, \
$data using 1:6 with lines lt 3, \
$data using 1:5:7 with filledcurves fs transparent solid 0.3 lc rgb "blue"
This function could be also assigned to the y2 axis with fixed y2range, which might be more handy for interactive plots with zooming.

Related

Shifting of axis title and sub-title in Gnuplot histogram

Mr data file is
# test.dat
# Sample No. Phenol Red Neutral Red Bromophenol Blue Bromocresol Green Mixed Indicator
1 80 69 223 222 130
2 89 62 321 267 160
3 92 67 248 276 147
Gnuplot code is
#
#
###
reset session
###
set terminal postscript eps enhanced colour font 'Times-Roman,12' size 6in,4in
set output "test.eps"
#------------------------------------------------------------------------------
set style line 1 lt 4 lw 1 lc rgb "#4169E1"
set style line 2 lt 4 lw 1 lc rgb "#2E8B57"
set style line 3 lt 5 lw 1 lc rgb "#FF4500"
set style line 4 lt 4 lw 1 lc rgb "#FAD02C"
set style line 5 lt 4 lw 1 lc rgb "#FF0080"
#------------------------------------------------------------------------------
set xtics out scale 1.5
set ytics out scale 1.5
set ytics nomirror
set yrange [0:350]
set key off
set tics font ", 16"
set xlabel "Sample No. " font ",16"
set ylabel "Moisture Content ({/Symbol \155}g of H_{2}O/g of melt)" font ",16"
set key samplen 2 spacing 1.65 font ",14" width -1.0
set key inside left horizontal
set style fill solid border
set style histogram clustered gap 1 title textcolor lt -1
# ----------------------------------------
set rmargin screen 0.9
set lmargin screen 0.1
set bmargin screen 0.4
# ----------------------------------------
set style data histogram
plot \
newhistogram "Direct titration", \
'test.dat' using 2:xtic(1) ls 4 axes x1y1 title "Phenol Red", \
'' u 3 ls 5 axes x1y1 title "Neutral Red", \
newhistogram "Back-titration", \
'test.dat.dat' using 4:xtic(1) ls 1 axes x1y1 title "Bromophenol Blue", \
'' u 5 ls 2 axes x1y1 title "Bromocresol Green", \
'' u 6 ls 3 axes x1y1 title "Mixed Indicator"
# ----------------------------------------
##
Script works fine. I would like to provide more spacing between the tick labels (1,2,3) and the sub-title (Direct titration and Back-titration) as well as spacing between the sub-titles and axis title. How can it be done?
set xlabel offset 0, -1 will shift both the subtitles and the axis title downward by one character height.
set xlabel "\nTEXT" will create a two-line axis label and place TEXT on the second line.
Modifying your xlabel command to be
set xlabel "\nSample No. " font ",16" offset 0,-1
will make both those changes.

Plot a error bar as shaded region in GNUPLOT

I have plotted a graph (X-top axis, Y-bottom axis) with fsteps function in Gnuplot. Next, I tried to add an error bar as a shaded region(transparent) to the graph, but unable to plot it on the graph. Below is the code so far I have tried and also attached the graph.
#!/usr/bin/gnuplot
reset
set border lw 30
set term pngcairo size 10000,10000 font "arial-Bold,130"
set output 'out.png'
unset key
set size ratio 1.2
set style data lines
set xtics format ""
set x2tics nomirror
set ytics out nomirror
set ytics 0,20
set x2label "Vs (km/s)" offset -1.0
set ylabel 'Depth (km)' offset 1.5
set xrange [2.5:4.8]
set yrange [314:0]
set label 3 at 2,120
set key samplen 1.7 at 3.0,135
#
set label 1 '(a)' font "arial-Bold,130" at 0.8,15 right
set label 3 "C3 (MNAI)" center font "arial-Bold,130"
set style fill transparent solid 0.25
set style fill noborder
plot 'MAN.inmd' lc rgb 'blue' lw 35 title "Initial model" with fsteps,\
'MAN.outmd' using 1:2 lc rgb 'red' lw 35 dt"-" title "Inverted model" with fsteps ,\
'MAN.outmd' using 1:($2-$3):($2+$3) with filledcurve lc "blue" notitle,
Example Data for file MAN.outmd X Y Z(Error)
0 3 0
0.4475 3.1 0
0.4475 3.5 0
2.6738 3.6 0.0552
2.6738 5 0.0552
3.8441 5.1 0.0592
3.8441 8 0.0592
3.6302 8.1 0.0395
3.6302 15.935 0.0395
4.5176 15.1 0.041
4.5176 113.296 0.041
4.2443 113.3 0.1024
4.2443 214 0.1024
4.4584 214.1 0.1077
4.4584 314 0.1077
I want output should be as given below (example)
gnuplot can easily fill the area between two "horizontal" curves (i.e. unique x-values), but as far as I know, not between two vertical curves. However, gnuplot can fill some enclosed areas. So, the workaround is to create datapoints which surround the area to be shaded. For this, you "plot" the data into a datablock, once "forward" with x-dx and once "backwards" with x+dx. This can be done easiest if you have the data already in a datablock, because then you can easily loop the data forward and backwards. In case you have your data in a file, see here: gnuplot: load datafile 1:1 into datablock
Code:
### fill between vertical curves
reset session
$Data <<EOD
0 3 0
0.4475 3.1 0
0.4475 3.5 0
2.6738 3.6 0.0552
2.6738 5 0.0552
3.8441 5.1 0.0592
3.8441 8 0.0592
3.6302 8.1 0.0395
3.6302 15.935 0.0395
4.5176 15.1 0.041
4.5176 113.296 0.041
4.2443 113.3 0.1024
4.2443 214 0.1024
4.4584 214.1 0.1077
4.4584 314 0.1077
EOD
# create datablock with circumference of shaded area
set print $XErrorFill
do for [i=1:|$Data|] {
print real(word($Data[i],1))-real(word($Data[i],3)), real(word($Data[i],2))
}
do for [i=|$Data|:1:-1] {
print real(word($Data[i],1))+real(word($Data[i],3)), real(word($Data[i],2))
}
set print
set yrange [:] reverse
set style fill noborder
plot $XErrorFill u 1:2 w filledcurves lc "light-grey" notitle, \
$Data u 1:2 w l lw 1.5 lc rgb "red" notitle
### end of code
Result:

How to make "filledcurves" change color when two or more meet? (GNUPlot)

I have created a graph that uses lines for the average of my data and filledcurves for the error (average-error, average+error). My problem is that the last filledcurves that is plotted, covers all other fills, even though I have set its transparency. I want to change this so that when two or more filledcurves meet the color is changed and thus the errors are clearly shown for all lines.
My script is:
set datafile separator whitespace
set style line 1 lc rgb '#aa5500' lt 1 lw 2 pt 7 ps 1
set style line 2 lc rgb '#55aaff' lt 1 lw 2 pt 7 ps 1
set style line 3 lc rgb '#aa557f' lt 1 lw 2 pt 7 ps 1
set style line 4 lc rgb '#55007f' lt 1 lw 2 pt 7 ps 1
set style line 5 lc rgb '#005500' lt 1 lw 2 pt 7 ps 1
set style line 6 lc rgb '#0055ff' lt 1 lw 2 pt 7 ps 1
set tics nomirror
set tics front
set style line 12 lc rgb '#808080' lt 0 lw 1
set grid front ls 12
set output 'network_utilization_servers_3_2.png'
set terminal png size 1000,800
set style fill transparent solid 0.25
set style fill noborder
set xrange[0:77]
set yrange[0:1500]
set xlabel "Time (seconds)" font ",12"
set ylabel "Incoming Traffic (KB/s)" font ",12"
set title "Network Utilization in the Servers" font "Helvetica,16"
set key box title "Server" width 10
plot for [i=0:|Group|-1] $Data3 u ($2-6):($3-$4):($3+$4) index i with filledcurves ls i+1 notitle, \
for [i=0:|Group|-1] $Data3 u ($2-6):3:4 index i w lines ti sprintf("%g",Group[i+1]) ls i+1
and my pragh:
My goal is something like this:
Is there a way to achieve this?

how to make rainbow box in GNUPLOT

I want to make a rainbow filled box on the visible light area with planck distribution curve.
I don't have any idea how to fill this box with rainbow...
I set a box like
set object 1 rectangle from 3600,0 to 8200,3.6 fs solid 0.4
and
fc rgb
is for coloring.
But only what I can do is fill it with one color.
I saw some coloring demos for plotting, like with pm3d or some palette,
but it doesn't put em onto obj coloring with palette.
it's from wiki and I want that rainbow box:
I actually wanted to make the exact same plot last year. I could not find a gnuplot solution (which I am pretty sure exists...), and in the end I wrote a script with an awk part to generate a file with RGB colors for a range of wavelengths, and then plotted those in gnuplot with impulses lc rgb variable. I used code from a few SO questions, but cannot remember the original sources. Anyway, using the code below:
#!/bin/bash
seq 4000 1 7000 | awk '{
wv=$1/10
if(wv < 380){
rd = -(380. - 440.) / (440. - 380.)
gr = 0.0
bl = 1.0}
if(wv >= 380 && wv < 440){
rd = -(wv - 440.) / (440. - 380.)
gr = 0.0
bl = 1.0}
if(wv >= 440 && wv < 490){
rd = 0.0
gr = (wv - 440.) / (490. - 440.)
bl = 1.0}
if(wv >= 490 && wv < 510){
rd = 0.0
gr = 1.0
bl = -(wv - 510.) / (510. - 490.)}
if(wv >= 510 && wv < 580){
rd = (wv - 510.) / (580. - 510.)
gr = 1.0
bl = 0.0}
if(wv >= 580 && wv < 645){
rd = 1.0
gr = -(wv - 645.) / (645. - 580.)
bl = 0.0}
if(wv >= 645 && wv <= 730){
rd = -(wv - 780.) / (780. - 645.)
gr = 0.0
bl = 0.0}
if(wv > 730){
rd = -(730 - 780.) / (780. - 645.)
gr = 0.0
bl = 0.0}
rgb=int(255*rd)*2^16+int(255*gr)*2^8+int(255*bl)
printf("%7.4f %f %f %f %f %3d %3d %3d %10d\n",$1/10000,41,rd,gr,bl,rd*255,gr*255,bl*255,rgb)
}' > rgb.tmp
gnuplot << GNU
set term pdf size 7,7 font "courier,16"
set output 'bblaw.pdf'
set encoding iso
set border -1 lw 0.90
set tics front
set style line 1 pt 7 ps 1.50 lt -1 lw 2.5 lc "#608DB6CD"
set style line 2 pt 5 ps 1.50 lt -1 lw 2.5 lc "#60EE6363"
set style line 3 pt 9 ps 1.00 lt -1 lw 2.5 lc "#FFB90F"
set style line 4 pt 5 ps 1.50 lt -1 lw 2.5 lc "#EEEEEE"
set xrange [0.10:1.65]
set yrange [0:41]
set ytics 5
set mytics 5
set xtics 0.25
set mxtics 5
set format x "%4.2f"
set ylabel "Intensity (kW . sr^{-1} . m^{-2} . {/Symbol m}m^{-1})"
set xlabel "Wavelength ({/Symbol m}m)"
set label "5000K" at 0.50,14.0 front font ",15"
set label "5500K" at 0.45,21.5 front font ",15"
set label "5778K (Sun)" at 0.40,27.0 front font ",15"
set label "6000K" at 0.45,32.5 front font ",15"
set label "8000K" at 0.22,39.0 front font ",15"
unset key
# length unit is micrometre
c=3e14 # speed of light
h=6.626e-22 # Planck constant
k=1.38e-11 # Boltzmann constant
# Planck curves
p1(x)=1e-6*2*h*c**2/(x**5*(exp(h*c/(x*k*5000))-1))
p2(x)=1e-6*2*h*c**2/(x**5*(exp(h*c/(x*k*5500))-1))
p3(x)=1e-6*2*h*c**2/(x**5*(exp(h*c/(x*k*5778))-1))
p4(x)=1e-6*2*h*c**2/(x**5*(exp(h*c/(x*k*6000))-1))
p5(x)=1e-6*2*h*c**2/(x**5*(exp(h*c/(x*k*8000))-1))
plot "rgb.tmp" u 1:2:9 not w imp lc rgb variable lw 0.5,\
p1(x) lw 6, p2(x) lw 6, p3(x) lw 6, p4(x) lw 6, p5(x) lw 6
GNU
rm rgb.tmp
You will get something like this:
If you run this bash script on your terminal, it should generate a pdf file and remove any temporary files that were created in the process. Note that you can change the awk script at the beginning, in case you want to move the color scale a bit. In this particular case, I limited the wavelength range to 4000:7000 angstroms by editing the seq command on line three.
Let me know if this solution works for you. If so, I'd suggest you add the awk tag to your question.
You can simply define a palette with the wavelengths and the approximate colors, like here.
Then use the colorbox as partial background of the plot.
Script: (works with gnuplot>=4.6.0, March 2012)
### Planck black-body radiation with visible spectrum (approximate)
reset
c = 299792458 # m/s
h = 6.62607015e-34 # Js
k = 1.380649e-23 # J/K
Planck(x,T) = 2*h*c**2/x**5/(exp(h*c/(x*k*T))-1)
set palette defined (380 "black", 400 "dark-violet", 440 "blue", 490 '#00b0c0', \
530 "green", 560 "yellow", 620 "red", 780 "black")
set style fill solid 0.4
unset cblabel
unset cbtics
set colorbox horizontal user origin first 380, graph 0 size first 400, graph 1 back
set key noautotitles
set grid x,y front
set xrange[100:2000]
plot for [T=4000:7000:1000] Planck(x/1e9,T) w l ti sprintf("%g K",T) lw 2, \
(NaN) w p palette # plot nothing just to get the colorbox
### end of script
Result: (created with gnuplot 4.6.0)
Its a bit of a manual solution, but how about a bunch of vertical lines. Here is a start. This linewidth is good for a plot window of 1200,900
set arrow 1 from 0.4,0 to 0.4, 50 nohead lc rgb '#8B008B#' lw 3.5
set arrow 2 from 0.405,0 to 0.405, 50 nohead lc rgb '#7000aF#' lw 3.5
set arrow 3 from 0.41,0 to 0.41, 50 nohead lc rgb '#4800FF#' lw 3.5
set arrow 4 from 0.415,0 to 0.415, 50 nohead lc rgb '#3000FF#' lw 3.5
set arrow 5 from 0.42,0 to 0.42, 50 nohead lc rgb '#1800FF#' lw 3.5
set arrow 6 from 0.425,0 to 0.425, 50 nohead lc rgb '#0000FF#' lw 3.5
set arrow 7 from 0.43,0 to 0.43, 50 nohead lc rgb '#0018FF#' lw 3.5
set arrow 8 from 0.435,0 to 0.435, 50 nohead lc rgb '#0030FF#' lw 3.5
set arrow 9 from 0.44,0 to 0.44, 50 nohead lc rgb '#0048FF#' lw 3.5
set arrow 10 from 0.445,0 to 0.445, 50 nohead lc rgb '#0060FF#' lw 3.5
set arrow 11 from 0.45,0 to 0.45, 50 nohead lc rgb '#0078FF#' lw 3.5
set arrow 12 from 0.455,0 to 0.455, 50 nohead lc rgb '#0088FF#' lw 3.5
set arrow 13 from 0.46,0 to 0.46, 50 nohead lc rgb '#0090FF#' lw 3.5
set arrow 14 from 0.465,0 to 0.465, 50 nohead lc rgb '#00a0FF#' lw 3.5
set arrow 15 from 0.47,0 to 0.47, 50 nohead lc rgb '#00b8FF#' lw 3.5
set arrow 16 from 0.475,0 to 0.475, 50 nohead lc rgb '#00d0FF#' lw 3.5
set arrow 17 from 0.48,0 to 0.48, 50 nohead lc rgb '#00fe8FF#' lw 3.5
set arrow 18 from 0.485,0 to 0.485, 50 nohead lc rgb '#00FFFF#' lw 3.5
set arrow 19 from 0.49,0 to 0.49, 50 nohead lc rgb '#7CFFa0#' lw 3.5
set arrow 20 from 0.495,0 to 0.495, 50 nohead lc rgb '#7CFF80#' lw 3.5
set arrow 21 from 0.5,0 to 0.5, 50 nohead lc rgb '#7CFF60#' lw 3.5
set arrow 22 from 0.505,0 to 0.505, 50 nohead lc rgb '#7CFF40#' lw 3.5
set arrow 23 from 0.51,0 to 0.51, 50 nohead lc rgb '#7CFF20#' lw 3.5
set arrow 24 from 0.515,0 to 0.515, 50 nohead lc rgb '#7CFF10#' lw 3.5
set arrow 25 from 0.52,0 to 0.52, 50 nohead lc rgb '#7CFF00#' lw 3.5
set arrow 26 from 0.525,0 to 0.525, 50 nohead lc rgb '#80FF00#' lw 3.5
set arrow 27 from 0.53,0 to 0.53, 50 nohead lc rgb '#88FF00#' lw 3.5
set arrow 28 from 0.535,0 to 0.535, 50 nohead lc rgb '#90FF00#' lw 3.5
set arrow 29 from 0.54,0 to 0.54, 50 nohead lc rgb '#98FF00#' lw 3.5
set arrow 30 from 0.545,0 to 0.545, 50 nohead lc rgb '#a0FF00#' lw 3.5
set arrow 31 from 0.55,0 to 0.55, 50 nohead lc rgb '#a8FF00#' lw 3.5
set arrow 32 from 0.555,0 to 0.555, 50 nohead lc rgb '#b0FF00#' lw 3.5
set arrow 33 from 0.56,0 to 0.56, 50 nohead lc rgb '#c0FF00#' lw 3.5
set arrow 34 from 0.565,0 to 0.565, 50 nohead lc rgb '#d0FF00#' lw 3.5
set arrow 35 from 0.57,0 to 0.57, 50 nohead lc rgb '#e0FF00#' lw 3.5
set arrow 36 from 0.575,0 to 0.575, 50 nohead lc rgb '#f0FF00#' lw 3.5
set arrow 37 from 0.58,0 to 0.58, 50 nohead lc rgb '#FFFF00#' lw 3.5
set arrow 38 from 0.585,0 to 0.585, 50 nohead lc rgb '#FFcF00#' lw 3.5
set arrow 39 from 0.59,0 to 0.59, 50 nohead lc rgb '#FFA500#' lw 3.5
set arrow 40 from 0.595,0 to 0.595, 50 nohead lc rgb '#FFA500#' lw 3.5
set arrow 41 from 0.6,0 to 0.6, 50 nohead lc rgb '#FF9800#' lw 3.5
set arrow 42 from 0.605,0 to 0.605, 50 nohead lc rgb '#FF8000#' lw 3.5
set arrow 43 from 0.61,0 to 0.61, 50 nohead lc rgb '#FF7000#' lw 3.5
set arrow 44 from 0.615,0 to 0.615, 50 nohead lc rgb '#FF6000#' lw 3.5
set arrow 45 from 0.62,0 to 0.62, 50 nohead lc rgb '#FF5000#' lw 3.5
set arrow 46 from 0.625,0 to 0.625, 50 nohead lc rgb '#FF4000#' lw 3.5
set arrow 47 from 0.63,0 to 0.63, 50 nohead lc rgb '#FF3800#' lw 3.5
set arrow 48 from 0.635,0 to 0.635, 50 nohead lc rgb '#FF3000#' lw 3.5
set arrow 49 from 0.64,0 to 0.64, 50 nohead lc rgb '#FF2000#' lw 3.5
set arrow 50 from 0.645,0 to 0.645, 50 nohead lc rgb '#FF1000#' lw 3.5
set arrow 51 from 0.65,0 to 0.65, 50 nohead lc rgb '#FF0000#' lw 3.5
set arrow 52 from 0.655,0 to 0.655, 50 nohead lc rgb '#FF0000#' lw 3.5
set arrow 53 from 0.66,0 to 0.66, 50 nohead lc rgb '#f00000#' lw 3.5
set arrow 54 from 0.665,0 to 0.665, 50 nohead lc rgb '#e00000#' lw 3.5
set arrow 55 from 0.67,0 to 0.67, 50 nohead lc rgb '#d00000#' lw 3.5
set arrow 56 from 0.675,0 to 0.675, 50 nohead lc rgb '#c00000#' lw 3.5
set arrow 57 from 0.68,0 to 0.68, 50 nohead lc rgb '#b00000#' lw 3.5
set arrow 58 from 0.685,0 to 0.685, 50 nohead lc rgb '#a00000#' lw 3.5
set arrow 59 from 0.69,0 to 0.69, 50 nohead lc rgb '#900000#' lw 3.5
set arrow 60 from 0.695,0 to 0.695, 50 nohead lc rgb '#800000#' lw 3.5
set arrow 61 from 0.7,0 to 0.7, 50 nohead lc rgb '#700000#' lw 3.5

Gnuplot set background color of data label

I want to set the background of data labels to white! The considered plot is a data plot of the following data (gnuDC.dat):
4 1570.96 1571
8 770.63 771
12 530.33 530
16 385.13 385
24 261.87 262
48 137.71 138
96 81.42 81
The plot command reads:
plot "gnuDC.dat" using 1:2 title "DC: GNU Fortran 4.7.2 + Open MPI 1.6.3" w p ls 1, \
"gnuDC.dat" using 1:2:3 with labels center offset 2.,0.7 font "Helvetica,14" tc ls 4 notitle, \
"gnuDC.dat" using 1:3 notitle smooth csplines ls 14
Which gives me:
It looks ok but think one could read the lables better when the would have an white background. Is there an easy way to add the white background for all labels at once?
Here is the whole print file:
set terminal postscript eps size 14cm,10cm enhanced color \
font 'Helvetica,18' linewidth 2
set output 'test.eps'
# Line style for axes
set style line 80 lt 0
set style line 80 lt rgb "#808080"
# Line style for grid
set style line 81 lt 3 # dashed
set style line 81 lt rgb "#808080" lw 0.5 # grey
set grid back linestyle 81
set border 3 back linestyle 80
set xtics nomirror
set ytics nomirror
set style line 100 lc rgb '#0060ad' lt 1 lw 2 pt 7 ps 1.5
set style line 200 lc rgb '#a2142f' lt 1 lw 2 pt 7 ps 1.5
set pointintervalbox 0
set style line 1 lc rgb '#0072bd' lt 1 lw 1 pt 9 pi -10 ps 2
set style line 2 lc rgb '#77ac30' lt 1 lw 1 pt 7 pi -10 ps 2
set style line 3 lc rgb '#d95319' lt 1 lw 1 pt 1 pi -10 ps 2
set bmargin 4
set lmargin 5
set rmargin 4
unset title
set size 1,1
#set origin 0,0.27
set xlabel "number of cores, -"
set ylabel "Computational time, s"
set key top right
set key spacing 1.5
set key width -12
set yrange [0:1710]
plot "gnuDC.dat" using 1:2 title "DC: GNU Fortran 4.7.2 + Open MPI 1.6.3" w p ls 1, \
"gnuDC.dat" using 1:2:3 with labels center offset 2.,0.7 font "Helvetica,14" tc ls 4 notitle, \
"gnuDC.dat" using 1:3 notitle smooth csplines ls 14
With gnuplot version 5 there is a boxed option which does exactly this: give labels a background and, if you want, also a border. The style is controlled with set style textbox, e.g.
set style textbox opaque noborder
plot ... with labels boxed ...
Applied to your script (with some minor changes due to the changed dash handling since 5.0):
# Line style for axes
set style line 80 lt rgb "#808080"
# Line style for grid
set style line 81 dt 3 # dashed
set style line 81 lt rgb "#808080" lw 0.5 # grey
set grid back linestyle 81
set border 3 back linestyle 80
set tics nomirror
set linetype 1 lc rgb '#0072bd' pt 9 pi -10 ps 2 dt 3
set bmargin 4
set lmargin 5
set rmargin 4
set xlabel "number of cores, -"
set ylabel "Computational time, s"
set key top right
set key spacing 1.5
set key width -12
set yrange [0:1710]
set style textbox opaque noborder
plot "gnuDC.dat" using 1:2 title "DC: GNU Fortran 4.7.2 + Open MPI 1.6.3" w p lt 1, \
"gnuDC.dat" using 1:2:3 with labels boxed center offset 2.,0.7 font "Helvetica,10" tc ls 1 notitle, \
"gnuDC.dat" using 1:3 notitle smooth csplines lt 1
No, for versions 4.6 and earlier there isn't an easy way to achieve this.

Resources