Gnuplot Charts Wild Fluctuations - gnuplot

I have a simple chart plotting off CSV data. Recently, there have been some wild fluctuations in the chart that I can't explain.
The chart:
The data:
"YYYY-MM-DD HH:MM:SS.SS","Pressure","Pressure Normal","Basement Temp","Downstairs Temp","Energy C1","Energy C2","Garage Temp","Lux","Lux Low","Indoor Hum","Main Attic Hum","Main Attic Temp","Outdoor Hum","Outdoor Temp","Outdoor Freeze","Rain Today","Septic Pump","Target Hum","Target Hum Low","Target Hum High","Upstairs Temp","Septic Low","Septic High","Wind Direction","Wind Speed"
2015-10-29 22:00:01.017000,29.95,30,68.0,69.0,639.986,381.38,45.0,0.0,30,49.0,39.0,49.0,94.0,46.0,32,0.0,176.884,45,15,45,66.0,165,185,139,2.0
2015-10-29 22:15:00.858000,29.96,30,68.0,69.0,526.95,283.151,45.0,0.0,30,49.0,39.0,48.9,92.0,46.0,32,0.0,178.132,45,15,45,67.0,165,185,146,2.0
2015-10-29 22:30:00.767000,29.96,30,68.0,68.0,462.525,362.072,45.0,0.0,30,49.0,39.0,48.8,92.0,46.0,32,0.0,178.654,45,15,45,66.0,165,185,138,5.0
2015-10-29 22:45:00.836000,29.97,30,68.0,68.0,473.075,274.232,45.0,0.0,30,49.0,39.0,48.4,91.0,46.0,32,0.0,179.509,45,15,45,66.0,165,185,147,2.0
2015-10-29 23:00:01.729000,29.98,30,68.0,68.0,460.024,355.895,45.0,0.0,30,49.0,39.0,48.3,89.0,46.0,32,0.0,179.626,45,15,45,66.0,165,185,150,2.0
2015-10-29 23:15:01.481000,29.99,30,68.0,68.0,470.404,266.078,44.0,0.0,30,49.0,39.0,48.1,90.0,46.0,32,0.0,179.759,45,15,45,66.0,165,185,140,1.0
2015-10-29 23:30:00.948000,29.99,30,67.0,67.0,578.765,361.633,44.0,0.0,30,49.0,39.0,48.1,90.0,45.0,32,0.0,181.606,45,15,45,65.0,165,185,143,0.0
2015-10-29 23:45:00.978000,29.99,30,67.0,67.0,578.813,265.008,44.0,0.0,30,48.0,39.0,47.7,90.0,45.0,32,0.0,180.662,45,15,45,65.0,165,185,143,0.0
2015-10-30 00:00:01.018000,30.0,30,67.0,67.0,571.851,358.56,44.0,0.0,30,48.0,39.0,47.6,90.0,45.0,32,0.0,182.406,45,15,45,65.0,165,185,154,0.0
2015-10-30 00:15:00.703000,30.0,30,67.0,67.0,461.92,266.449,44.0,0.0,30,48.0,40.0,47.5,90.0,45.0,32,0.0,179.058,45,15,45,65.0,165,185,170,1.0
2015-10-30 00:30:00.676000,30.0,30,68.0,67.0,459.044,364.956,44.0,0.0,30,48.0,40.0,47.3,90.0,45.0,32,0.0,176.376,45,15,45,65.0,165,185,152,1.0
2015-10-30 00:45:01.742000,30.0,30,67.0,67.0,464.856,268.456,44.0,0.0,30,49.0,40.0,47.2,90.0,45.0,32,0.0,178.552,45,15,45,65.0,165,185,160,0.0
2015-10-30 01:00:01.412000,30.0,30,67.0,67.0,462.717,373.676,44.0,0.0,30,48.0,40.0,47.0,91.0,45.0,32,0.0,177.563,45,15,45,65.0,165,185,140,1.0
2015-10-30 01:15:01.398000,30.0,30,67.0,66.0,465.183,265.674,44.0,0.0,30,48.0,40.0,46.9,91.0,45.0,32,0.0,179.081,45,15,45,64.0,165,185,139,1.0
2015-10-30 01:30:01.690000,30.0,30,67.0,66.0,466.075,276.496,43.0,0.0,30,48.0,40.0,46.8,91.0,45.0,32,0.0,178.243,45,15,45,64.0,165,185,125,0.0
2015-10-30 01:45:01.222000,30.01,30,67.0,66.0,583.214,266.92,43.0,0.0,30,48.0,40.0,46.5,90.0,45.0,32,0.0,179.797,45,15,45,64.0,165,185,125,0.0
2015-10-30 02:00:01.147000,30.02,30,67.0,66.0,577.097,265.52,43.0,0.0,30,48.0,40.0,46.3,90.0,45.0,32,0.0,180.246,45,15,45,64.0,165,185,161,0.0
2015-10-30 02:15:01.130000,30.03,30,67.0,66.0,570.447,268.758,43.0,0.0,30,48.0,40.0,46.2,92.0,45.0,32,0.0,181.472,45,15,45,64.0,165,185,140,0.0
2015-10-30 02:30:01.124000,30.03,30,67.0,66.0,466.977,266.9,43.0,0.0,30,48.0,40.0,46.1,92.0,44.0,32,0.0,179.358,45,15,45,64.0,165,185,157,0.0
2015-10-30 02:45:00.935000,30.03,30,67.0,66.0,467.547,265.461,43.0,0.0,30,47.0,40.0,45.7,92.0,44.0,32,0.0,178.06,45,15,45,64.0,165,185,148,0.0
2015-10-30 03:00:00.730000,30.04,30,67.0,65.0,467.852,270.395,42.0,0.0,30,48.0,41.0,45.5,91.0,44.0,32,0.0,180.963,45,15,45,64.0,165,185,148,0.0
2015-10-30 03:15:00.669000,30.05,30,67.0,65.0,470.797,269.087,42.0,0.0,30,48.0,41.0,45.1,91.0,43.0,32,0.0,181.562,45,15,45,64.0,165,185,148,0.0
2015-10-30 03:30:00.597000,30.06,30,67.0,65.0,471.425,266.515,41.0,0.0,30,48.0,41.0,44.7,91.0,43.0,32,0.0,181.108,45,15,45,64.0,165,185,148,0.0
2015-10-30 03:45:01.544000,30.06,30,67.0,65.0,466.103,266.759,41.0,0.0,30,48.0,41.0,44.6,92.0,42.0,32,0.0,181.674,45,15,45,65.0,165,185,148,0.0
2015-10-30 04:00:01.428000,30.06,30,67.0,65.0,468.903,269.099,41.0,0.0,30,48.0,41.0,44.4,92.0,42.0,32,0.0,181.132,45,15,45,64.0,165,185,148,0.0
2015-10-30 04:15:01.112000,30.07,30,67.0,64.0,1133.93,265.94,40.0,0.0,30,48.0,41.0,44.0,92.0,42.0,32,0.0,178.97,45,15,45,63.0,165,185,148,0.0
2015-10-30 04:30:01.129000,30.08,30,67.0,65.0,575.551,269.082,40.0,0.0,30,48.0,41.0,43.8,94.0,41.0,32,0.0,179.605,45,15,45,64.0,165,185,143,0.0
2015-10-30 04:45:00.949000,30.08,30,67.0,64.0,2912.436,342.048,40.0,0.0,30,48.0,41.0,43.7,95.0,42.0,32,0.0,179.017,45,15,45,64.0,165,185,168,0.0
2015-10-30 05:00:00.969000,30.09,30,67.0,66.0,550.604,279.568,40.0,0.0,30,49.0,41.0,44.8,95.0,42.0,32,0.0,177.197,45,15,45,68.0,165,185,184,2.0
2015-10-30 05:15:00.709000,30.1,30,67.0,66.0,586.835,549.631,40.0,0.0,30,49.0,41.0,45.4,95.0,41.0,32,0.0,178.466,45,15,45,69.0,165,185,148,1.0
2015-10-30 05:30:00.901000,30.1,30,67.0,66.0,596.532,278.354,39.0,0.0,30,49.0,41.0,46.1,95.0,41.0,32,0.0,175.013,45,15,45,70.0,165,185,161,1.0
2015-10-30 05:45:01.672000,30.1,30,67.0,65.0,1506.813,1119.999,39.0,0.0,30,50.0,41.0,46.2,95.0,41.0,32,0.0,174.623,45,15,45,67.0,165,185,155,0.0
2015-10-30 06:00:01.509000,30.12,30,68.0,67.0,1516.573,266.874,39.0,0.0,30,49.0,41.0,46.6,95.0,41.0,32,0.0,175.143,45,15,45,69.0,165,185,155,0.0
2015-10-30 06:15:01.207000,30.12,30,68.0,68.0,1072.979,376.114,39.0,0.0,30,49.0,41.0,46.7,95.0,41.0,32,0.0,172.09,45,15,45,69.0,165,185,155,0.0
2015-10-30 06:30:01.312000,30.12,30,69.0,70.0,854.998,281.418,38.0,0.0,30,49.0,41.0,46.6,95.0,40.0,32,0.0,172.968,45,15,45,69.0,165,185,155,0.0
2015-10-30 06:45:01.234000,30.12,30,69.0,69.0,596.209,374.564,38.0,0.0,30,49.0,41.0,45.1,95.0,40.0,32,0.0,174.648,45,15,45,68.0,165,185,155,0.0
2015-10-30 07:00:00.883000,30.12,30,68.0,68.0,596.669,279.735,38.0,0.0,30,49.0,41.0,44.5,95.0,40.0,32,0.0,175.019,45,15,45,67.0,165,185,155,0.0
2015-10-30 07:15:01.066000,30.12,30,68.0,68.0,489.209,376.154,38.0,0.0,30,49.0,41.0,44.0,96.0,41.0,32,0.0,175.471,45,15,45,66.0,165,185,155,0.0
2015-10-30 07:30:01.019000,30.12,30,68.0,67.0,398.586,269.955,38.0,0.0,30,49.0,41.0,43.5,96.0,41.0,32,0.0,178.401,45,15,45,66.0,165,185,155,0.0
2015-10-30 07:45:00.784000,30.12,30,68.0,67.0,397.613,369.828,37.0,0.0,30,49.0,42.0,42.8,96.0,41.0,32,0.0,176.625,45,15,45,66.0,165,185,155,0.0
2015-10-30 08:00:00.919000,30.13,30,67.0,67.0,394.231,284.606,37.0,0.0,30,48.0,42.0,42.6,96.0,41.0,32,0.0,176.026,45,15,45,65.0,165,185,155,0.0
2015-10-30 08:15:00.672000,30.14,30,67.0,66.0,403.669,373.851,37.0,0.0,30,48.0,42.0,42.4,96.0,41.0,32,0.0,180.215,45,15,45,65.0,165,185,156,0.0
2015-10-30 08:30:00.527000,30.13,30,67.0,66.0,391.887,268.734,37.0,0.0,30,48.0,42.0,42.5,96.0,42.0,32,0.0,172.674,45,15,45,65.0,165,185,146,0.0
2015-10-30 08:45:01.630000,30.13,30,67.0,66.0,388.044,265.381,38.0,0.0,30,48.0,43.0,43.8,97.0,42.0,32,0.0,174.12,45,15,45,65.0,165,185,125,1.0
2015-10-30 09:00:01.461000,30.14,30,67.0,66.0,506.085,263.921,38.0,0.0,30,49.0,43.0,44.7,97.0,42.0,32,0.0,174.449,45,15,45,65.0,165,185,36,0.0
2015-10-30 09:15:01.443000,30.15,30,67.0,66.0,515.15,270.162,39.0,0.0,30,48.0,43.0,45.7,97.0,43.0,32,0.0,173.922,45,15,45,65.0,165,185,342,0.0
2015-10-30 09:30:01.428000,30.16,30,67.0,66.0,503.095,266.903,39.0,0.0,30,48.0,43.0,46.8,97.0,44.0,32,0.0,179.962,45,15,45,64.0,165,185,53,0.0
2015-10-30 09:45:01.175000,30.16,30,67.0,66.0,406.591,268.547,40.0,0.0,30,48.0,43.0,49.3,97.0,45.0,32,0.0,180.893,45,15,45,64.0,165,185,286,1.0
2015-10-30 10:00:01.024000,30.17,30,67.0,66.0,408.512,267.207,41.0,0.0,30,48.0,43.0,50.8,97.0,46.0,32,0.0,182.111,45,15,45,64.0,165,185,240,1.0
The script (run on Gnuplot 5.0 patch 0):
#! /usr/bin/env gnuplot
reset
#### Stats and Setup ####
set terminal pngcairo enhanced background "#000000" font "Arial,10" size 400,200 truecolor
datafile_temperatures_indoor = "/Users/username/Dropbox/Public/charts.csv"
set datafile separator ','
stats datafile_temperatures_indoor using 2 nooutput
set timefmt "%Y-%m-%d %H:%M:%S"
set output "/Users/username/Dropbox/Public/TemperaturesIndoor.png"
now = time(0)
today_midnight = strptime('%Y-%m-%d', strftime('%Y-%m-%d', now))
#### Plot Parameters and Styles ####
set tics textcolor rgb "#666666"
set border linetype rgb "#666666"
set boxwidth 0.25 relative
set style fill solid 1.0
set style line 1 linetype rgb "#FFFFFF" linewidth 1 pointtype 6 # white
set style line 2 linetype rgb "#333333" linewidth 1 pointtype 6 # light gray
set style line 3 linetype rgb "#666666" linewidth 1 pointtype 6 # gray
set style line 4 linetype rgb "#999999" linewidth 1 pointtype 6 # dark gray
set style line 5 linetype rgb "#000000" linewidth 1 pointtype 6 # black
set style line 6 linetype rgb "#FF3333" linewidth 1 pointtype 6 # red
set style line 7 linetype rgb "#FF6600" linewidth 1 pointtype 6 # orange
set style line 8 linetype rgb "#FFFF00" linewidth 1 pointtype 6 # yellow
set style line 9 linetype rgb "#336600" linewidth 1 pointtype 6 # green
set style line 10 linetype rgb "#0000FF" linewidth 1 pointtype 6 # blue
set style line 11 linetype rgb "#000033" linewidth 1 pointtype 6 # indigo
set style line 12 linetype rgb "#6600FF" linewidth 1 pointtype 6 # violet
#### Key Parameters ####
set nokey
#### X Axis Parameters ####
unset mxtics
set xdata time
set xrange [now - 72*60*60 : now]
set xtics 72*60*60, 24*60*60 format "%a" nomirror
#### Y Axis Parameters ####
set ytics format "%2.0f" nomirror
#### Plot the Data ####
plot datafile_temperatures_indoor using 1:4 every ::2 title column with lines smooth csplines linestyle 8,\
datafile_temperatures_indoor using 1:5 every ::2 title column with lines smooth csplines linestyle 12,\
datafile_temperatures_indoor using 1:22 every ::2 title column with lines smooth csplines linestyle 6
The stats:
* FILE:
Records: 319
Out of range: 0
Invalid: 0
Blank: 0
Data Blocks: 1
* COLUMN:
Mean: 66.3856
Std Dev: 1.7577
Sample StdDev: 1.7605
Skewness: 0.5592
Kurtosis: 2.5369
Avg Dev: 0.9624
Sum: 21177.0000
Sum Sq.: 1.40683e+06
Mean Err.: 0.0984
Std Dev Err.: 0.0696
Skewness Err.: 0.1371
Kurtosis Err.: 0.2743
Minimum: 63.0000 [ 25]
Maximum: 71.0000 [267]
Quartile: 65.0000
Median: 66.0000
Quartile: 67.0000
I don't see an out of range value in the data; sometimes the out of range obs is wildly negative (-60), sometimes wildly positive +240). I'm wondering if there's a bug in the implementation of csplines under 5.0. Any advice would be most appreciated.
Cheers.
[EDIT] With mcsplines:
With Bezier (which I think I prefer):

Related

How to plot several Y axis in the left side using gnuplot

I am plotting same plot as from here How to plot multiple y-axes?. But also i would like them to look like in the image below. With additional lines and tics, how can i do it?
As mentioned in the answer you linked, you can plot many plots on top of each other in the multiplot environment.
So, here you are plotting 6 plots on top of each other
plot 1, 2, 3 for the data/functions
plot 4, 5, 6 for the colored axes
and plot 6 as well for the key on top of everything
In order to get the same scale for the plot and the "external" axes I would recommend to store the ranges and step sizes in the variables y10,y11,y1d, ...., such that you have to change the values only at one location.
Script:
reset session
set key opaque box noautotitle
set multiplot
set margins screen 0.3, screen 0.95, screen 0.95, screen 0.1 # l,r,t,b
# first plot
set xrange[0:10]
set xtics 2
y10 = -1.2
y11 = 1.2
y1d = 0.4
set yrange [y10:y11]
set ytics y1d
set format y '' # no ytic labels
set grid x,y
plot sin(x) lc "red"
# second plot
set border 0 # no border
unset tics # no tics
unset grid # no grid
y20 = -3.0
y21 = 3.0
y2d = 1.0
set yrange [y20:y21]
plot 3*cos(x) lc "green"
# third plot
y30 = -1.5
y31 = 1.5
y3d = 0.5
set yrange [y30:y31]
plot 3*sin(x)*cos(x) lc "blue"
# plot for axis 1
set lmargin screen 0.27
set border 2 lc "red" lw 2
set ylabel "Voltage" tc "red" offset 1.5,0
set yrange [y10:y11]
set format y
set ytics y1d nomirror
plot NaN
# plot for axis 2
set lmargin screen 0.17
set border 2 lc "green" lw 2
set ylabel "Current" tc "green" offset 0.5,0
set yrange [y20:y21]
set ytics y2d
plot NaN
# plot for axis 3 and key
set lmargin screen 0.08
set border 2 lc "blue" lw 2
set ylabel "Power" tc "blue" offset 1,0
set yrange [y30:y31]
set ytics y3d
plot NaN w l lc "red" ti "sin(x)", \
NaN w l lc "green" ti "3*cos(x)", \
NaN w l lc "blue" ti "3*sin(x)*cos(x)"
unset multiplot
### end of script
Result:

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:

Equal frame size in a multiplot 3x4

I have the following multiplot
set encoding iso_8859_1
set xtics font "Helvetica,16"
set ytics font "Helvetica,16"
set terminal postscript eps enhanced color size 12in,6in
set grid
set key box vertical width 2 height 0.75 maxcols 1 #spacing 1
load "../estilos.txt"
# TMARGIN = "set tmargin at screen 0.90; set bmargin at screen 0.55"
# BMARGIN = "set tmargin at screen 0.55; set bmargin at screen 0.20"
# LMARGIN = "set lmargin at screen 0.15; set rmargin at screen 0.55"
# RMARGIN = "set lmargin at screen 0.55; set rmargin at screen 0.95"
############################################################################################
set output "_Mult_16R_4Chk_mp.eps"
set title "Minimum number of contention intervals, {/Symbol D}=1" font "Helvetica,17"
set multiplot layout 3,4 columnsfirst
set xlabel ""
set ylabel "T [s]" font "Helvetica,19"
set key top left font "Helvetica,16"
# #TMARGIN #LMARGIN
plot [0:40][0:140] "contention_1/sys-time-4-16-80-15-2.txt" u ($1/60):2 every 2 ls 20 ps 0.35 title "MSL=80%"
set title ""
set key top left font "Helvetica,16"
set ylabel "Queue length [batches]" font "Helvetica,19"
# #BMARGIN; #LMARGIN
plot [0:40][0:70] "contention_1/queue-length-4-16-50-15-1.txt" using ($1/60):2 every 2 with lines ls 20 lw 1.5 title "MSL=50%" ,\
"contention_1/queue-length-4-16-80-15-2.txt" using ($1/60):2 every 2 with lines ls 2200 lw 1.5 title "MSL=80%" ,\
"contention_1/queue-length-4-16-98-15-3.txt" using ($1/60):2 every 2 with lines ls 5550 lw 1.5 title "MSL=98%"
set key bottom right font "Helvetica,16"
set ylabel "Inventory ratio, {/Symbol g}" font "Helvetica,19"
set xlabel "Operation time [minutes]" font "Helvetica,19"
# #BMARGIN; #LMARGIN
plot [0:40][0:1] "contention_1/known-ratio-4-16-50-15-1.txt" using ($1/60):2 every 2 w linespoints ls 20 ps 0.75 lw 1.5 title "MSL=50%" ,\
"contention_1/known-ratio-4-16-80-15-2.txt" using ($1/60):2 every 2 w linespoints ls 2200 ps 0.75 lw 1.5 title "MSL=80%" ,\
"contention_1/known-ratio-4-16-98-15-3.txt" using ($1/60):2 every 2 w linespoints ls 5550 ps 0.75 lw 1.5 title "MSL=98%"
############################################################################################
set title "Minimum number of contention intervals, {/Symbol D}=100" font "Helvetica,17"
set xlabel ""
set ylabel ""
set key top left font "Helvetica,16"
plot [0:40][0:140] "contention_100/sys-time-4-16-80-15-2.txt" u ($1/60):2 every 2 ls 20 ps 0.35 title "MSL=80%"
set title ""
set key top left font "Helvetica,16"
plot [0:40][0:70] "contention_100/queue-length-4-16-50-15-1.txt" using ($1/60):2 every 2 with lines ls 20 lw 1.5 title "MSL=50%" ,\
"contention_100/queue-length-4-16-80-15-2.txt" using ($1/60):2 every 2 with lines ls 2200 lw 1.5 title "MSL=80%" ,\
"contention_100/queue-length-4-16-98-15-3.txt" using ($1/60):2 every 2 with lines ls 5550 lw 1.5 title "MSL=98%"
set key bottom right font "Helvetica,16"
set xlabel "Operation time [minutes]" font "Helvetica,19"
plot [0:40][0:1] "contention_100/known-ratio-4-16-50-15-1.txt" using ($1/60):2 every 2 w linespoints ls 20 ps 0.75 lw 1.5 title "MSL=50%" ,\
"contention_100/known-ratio-4-16-80-15-2.txt" using ($1/60):2 every 2 w linespoints ls 2200 ps 0.75 lw 1.5 title "MSL=80%" ,\
"contention_100/known-ratio-4-16-98-15-3.txt" using ($1/60):2 every 2 w linespoints ls 5550 ps 0.75 lw 1.5 title "MSL=98%"
############################################################################################
set title "Minimum number of contention intervals, {/Symbol D}=200" font "Helvetica,17"
set xlabel ""
set ylabel ""
set key top left font "Helvetica,16"
plot [0:40][0:140] "contention_200/sys-time-4-16-80-15-2.txt" u ($1/60):2 every 2 ls 20 ps 0.35 title "MSL=80%"
set title ""
set key top left font "Helvetica,16"
plot [0:40][0:70] "contention_200/queue-length-4-16-50-15-1.txt" using ($1/60):2 every 2 with lines ls 20 lw 1.5 title "MSL=50%" ,\
"contention_200/queue-length-4-16-80-15-2.txt" using ($1/60):2 every 2 with lines ls 2200 lw 1.5 title "MSL=80%" ,\
"contention_200/queue-length-4-16-98-15-3.txt" using ($1/60):2 every 2 with lines ls 5550 lw 1.5 title "MSL=98%"
set key bottom right font "Helvetica,16"
set xlabel "Operation time [minutes]" font "Helvetica,19"
plot [0:40][0:1] "contention_200/known-ratio-4-16-50-15-1.txt" using ($1/60):2 every 2 w linespoints ls 20 ps 0.75 lw 1.5 title "MSL=50%" ,\
"contention_200/known-ratio-4-16-80-15-2.txt" using ($1/60):2 every 2 w linespoints ls 2200 ps 0.75 lw 1.5 title "MSL=80%" ,\
"contention_200/known-ratio-4-16-98-15-3.txt" using ($1/60):2 every 2 w linespoints ls 5550 ps 0.75 lw 1.5 title "MSL=98%"
############################################################################################
set title "Minimum number of contention intervals, {/Symbol D}=300" font "Helvetica,17"
set xlabel ""
set ylabel ""
# set ylabel "T [s]" font "Helvetica,19"
set key top left font "Helvetica,16"
plot [0:40][0:140] "contention_300/sys-time-4-16-80-15-300-2.txt" u ($1/60):2 every 2 ls 20 ps 0.35 title "MSL=80%"
set title ""
set key top left font "Helvetica,16"
plot [0:40][0:70] "contention_300/queue-length-4-16-50-15-300-1.txt" using ($1/60):2 every 2 with lines ls 20 lw 1.5 title "MSL=50%" ,\
"contention_300/queue-length-4-16-80-15-300-2.txt" using ($1/60):2 every 2 with lines ls 2200 lw 1.5 title "MSL=80%" ,\
"contention_300/queue-length-4-16-98-15-300-3.txt" using ($1/60):2 every 2 with lines ls 5550 lw 1.5 title "MSL=98%"
set key bottom right font "Helvetica,16"
set xlabel "Operation time [minutes]" font "Helvetica,19"
plot [0:40][0:1] "contention_300/known-ratio-4-16-50-15-300-1.txt" using ($1/60):2 every 2 w linespoints ls 20 ps 0.75 lw 1.5 title "MSL=50%" ,\
"contention_300/known-ratio-4-16-80-15-300-2.txt" using ($1/60):2 every 2 w linespoints ls 2200 ps 0.75 lw 1.5 title "MSL=80%" ,\
"contention_300/known-ratio-4-16-98-15-300-3.txt" using ($1/60):2 every 2 w linespoints ls 5550 ps 0.75 lw 1.5 title "MSL=98%"
unset multiplot
The data files are linked here.
The plot looks like this:
which has the information I want to show.
However, the frames are not equal in size. For example, the first row is shorter because it has titles, the middle row of plots is bigger, and the bottom row is also small. The widths of single plots are differents too.
I have seen in this post of Gnuplotting Multiplot – placing graphs next to each other that using set l/b/r/tmargin at screen value is the way to set the sizes of the frames in a multiplot 2x2, but in my case multiplot 3x4 and with tics and separation between single plots result more difficult to achieve.
To my opinion, you probably should forget about set multiplot layout 3,4. Instead, set the sizes and origins of the plots yourself and insert the titles and xlabels as labels at the top and at the bottom. Then use a few parameters to tune your layout. If the code might not be self-explaining enough do not hesitate to ask.
Code:
### customized multiplot
reset session
# Parameters to tune
PlotRows = 3
PlotCols = 4
TitlePosY = 0.98
MultiPlotTop = 0.93
SizeScalingX = 0.90
SizeScalingY = 0.95
MultiPlotBottom = 0.05
XLabelPosY = 0.03
MultiPlotLeft = 0.07
YLabelPosX = 0.02
set lmargin 2
# define origin functions
PlotGridX = (1-MultiPlotLeft)/PlotCols
PlotOriginX(n) = ((n-1)%PlotCols)*PlotGridX + MultiPlotLeft
PlotGridY = (MultiPlotTop-MultiPlotBottom)/PlotRows
PlotOriginY(n) = (PlotRows-1-int((n-1)/PlotCols))*PlotGridY + MultiPlotBottom
# set size
set size SizeScalingX*(1-MultiPlotLeft)/PlotCols, SizeScalingY*(MultiPlotTop+MultiPlotBottom)/PlotRows
# set your titles and labels
TitleStd = "Minimum number of \ncontention intervals, {/Symbol D}="
TitleVar = "1 100 200 300"
XLabelStd = "Operation time [minutes]"
do for [i=1:PlotCols] {
set label i at screen PlotOriginX(i), screen TitlePosY TitleStd.word(TitleVar,i) font "Helvetica,8"
set label i+10 at screen PlotOriginX(i), screen XLabelPosY XLabelStd font "Helvetica,8"
}
YLabels = '"T [s]" "Queue length [batches]" "Inventory ratio, {/Symbol g}"'
do for [i=1:PlotRows] {
set label i+20 at screen YLabelPosX, screen PlotOriginY(i*PlotCols)+PlotGridY*0.5 word(YLabels,i) rotate by 90 center
}
set multiplot
do for [i=1:12] { # do your 3x4 plots here and increase "counter" i after each plot
set origin PlotOriginX(i), PlotOriginY(i)
plot 10**((i-1)/4)*sin(0.1*i*x) notitle
}
unset multiplot
### end of code
Result:

Can't get gnuplot to fill below line

I'm trying to get gnuplot 5.0 under OS X 10.10.3 to fill blue below the lower series in this plot. I've tried lots of variations for the line dataFileForecast using 1:4 with filledcurves above y1=0 linestyle 3, but nothing seems to work.
Here's the source:
#!/opt/local/bin/gnuplot
reset
set terminal pngcairo enhanced background "#000000" font "Lato-Light,20" linewidth 1 rounded size 2048,670
set output "10DayForecast.png"
dataFileForecast = "10DayForecast.csv"
set datafile separator ','
set timefmt "%Y-%m-%d"
stats dataFileForecast using 2:4 nooutput
freezeWarning = 32.
Yhigh = STATS_max_x + 10.
Ylow = STATS_min_y - 10.
unset key
set border linetype rgb "#666666"
set boxwidth 0.25 relative
set style fill transparent solid 0.4
set style line 1 linetype rgb "#0066CC" # freeze line
set style line 2 linetype rgb "#FFFFFF" pointtype 7 pointsize .5 # points for both high and low temp
set style line 3 linetype rgb "#000077" # fill for low temp
set style line 4 linetype rgb "#FFFF00" # rain forecast
set style line 5 linetype rgb "#770000" # fill for high temp
set style line 6 linetype rgb "#FF7777" # line for high temp
set style line 7 linetype rgb "#3377FF" # line for low temp
set label "°" right
unset mxtics
set tics textcolor rgb "#666666"
# X Axis
set xdata time
set xtics format "%a" nomirror
set autoscale xfix
set offsets 12*60*60,12*60*60,0,0
# Y Axis
set yrange [Ylow:Yhigh]
unset ytics
if (32 > Ylow) set ytics 32,1,32 tc rgb "#FFFFFF" font ",18"
set ytics format "%2.0f°" nomirror
# Y2 Axis
set y2tics format "%2.0f%%" textcolor "#FFFF00" nomirror
set y2range [0:100]
plot dataFileForecast using 1:6 with impulses linestyle 4 axes x1y2,\
dataFileForecast using 1:2:4 with filledcurves above linestyle 5,\
dataFileForecast using 1:2 with lines linestyle 6,\
dataFileForecast using 1:2 with points linestyle 2,\
dataFileForecast using 1:2:3 with labels offset 1.75,0.5 textcolor "#FFFFFF" font ",18",\
dataFileForecast using 1:4 with filledcurves above y1=0 linestyle 3,\
dataFileForecast using 1:4 with lines linestyle 7,\
dataFileForecast using 1:4 with points linestyle 2,\
dataFileForecast using 1:4:5 with labels offset 1.75,0.5 textcolor "#FFFFFF" font ",18",\
freezeWarning with filledcurve above y1=0 linestyle 1
And here's a data file:
2015-06-29,94,94°,69,69°,20.0
2015-06-30,99,99°,72,72°,0.0
2015-07-01,102,102°,73,73°,0.0
2015-07-02,96,96°,69,69°,0.0
2015-07-03,94,94°,68,68°,10.0
2015-07-04,92,92°,67,67°,0.0
2015-07-05,91,91°,63,63°,0.0
2015-07-06,91,91°,62,62°,0.0
2015-07-07,91,91°,61,61°,0.0
2015-07-08,91,91°,63,63°,0.0
What am I missing?
I'm not sure, why this doesn't work. Could be a bug. As workaround you can give a third column in the using statement to indicate the lower boundary of the filled area:
plot ...,\
dataFileForecast using 1:4:(0) with filledcurves linestyle 3
This gives the output
The freezeWarning area is plotted correctly, if the yrange includes this region.

Resources