I am trying to plot a clustered box-and-whisker plots in gnuplot for two files and I want the outputs to share the same xtics. Instead, I get an xtic for each file. This is my script:
set term pdf color enhanced
#set output ".pdf"
set bar 2
set style fill empty
set ylabel "Link Speed (kbps)"
set xlabel "Rate (Mbps)"
set grid
plot "file1.txt" using ($1-0.05):5:4:10:9:xticlabels(2) with candlesticks title "video" whiskerbars lw 3 lt 2, \
"" using ($1-0.05):7:7:7:7:xticlabels(2) with candlesticks lt 2 lw 5 notitle, \
"" using ($1-0.05):3:xticlabels(2) with points lt 18 pt 7 ps 0.7 notitle, \
"file2.txt" using ($1+0.05):5:4:10:9:xticlabels(2) with candlesticks title "tcp" whiskerbars lw 3 lt 3, \
"" using ($1+0.05):7:7:7:7:xticlabels(2) with candlesticks lt 3 lw 5 notitle, \
"" using ($1+0.05):3:xticlabels(2) with points lt 18 pt 7 ps 0.7 notitle
Related
My test.dat file is given below
6.78E-01 -1.907881356 -1.938152542 -1.994762712 -4.409491525 -3.707118644 -2.623559322 -1.903389831 -1.891452492 -1.880469492 -2.009079661 -1.835169492 -2.193627119
6.73E-01 -1.828333333 -1.861727273 -1.916205387 -4.308956229 -3.614276094 -2.547508418 -1.823097643 -1.811922731 -1.800939731 -1.930919529 -1.757255892 -2.114855219
6.69E-01 -1.749849498 -1.786324415 -1.838698997 -4.209765886 -3.522675585 -2.472474916 -1.743879599 -1.733456913 -1.722473913 -1.853805017 -1.680384615 -2.037137124
6.64E-01 -1.672408638 -1.711923588 -1.762222591 -4.111893688 -3.432292359 -2.398438538 -1.665714286 -1.656033831 -1.645050831 -1.777715282 -1.604534884 -1.960451827
6.60E-01 -1.595990099 -1.63850495 -1.686755776 -4.015313531 -3.34310231 -2.325379538 -1.588580858 -1.579632835 -1.568649835 -1.702630033 -1.529686469 -1.884778878
6.56E-01 -1.52057377 -1.56604918 -1.612278689 -3.92 -3.255081967 -2.253278689 -1.512459016 -1.50423382 -1.49325082 -1.628529508 -1.455819672 -1.810098361
6.51E-01 -1.446140065 -1.494537459 -1.538771987 -3.825928339 -3.168208469 -2.182117264 -1.43732899 -1.429817202 -1.418834202 -1.555394463 -1.382915309 -1.736390879
6.47E-01 -1.372669903 -1.423951456 -1.466216828 -3.733074434 -3.082459547 -2.111877023 -1.363171521 -1.356363906 -1.345380906 -1.483206149 -1.310954693 -1.66363754
6.43E-01 -1.300144695 -1.354273312 -1.394594855 -3.641414791 -2.997813505 -2.042540193 -1.289967846 -1.283855347 -1.272872347 -1.411946302 -1.239919614 -1.591819936
6.39E-01 -1.228546326 -1.285485623 -1.323888179 -3.550926518 -2.914249201 -1.974089457 -1.217699681 -1.212273415 -1.201290415 -1.341597125 -1.169792332 -1.520920128
6.35E-01 -1.157857143 -1.217571429 -1.254079365 -3.461587302 -2.831746032 -1.906507937 -1.146349206 -1.14160046 -1.13061746 -1.27214127 -1.100555556 -1.450920635
6.31E-01 -1.088059937 -1.150514196 -1.18515142 -3.373375394 -2.750283912 -1.83977918 -1.075899054 -1.071819278 -1.060836278 -1.20356183 -1.032192429 -1.381804416
6.27E-01 -1.019137931 -1.084297806 -1.117087774 -3.286269592 -2.66984326 -1.773887147 -1.006332288 -1.002913094 -0.991930094 -1.13584232 -0.96468652 -1.313554859
6.23E-01 -0.951074766 -1.018906542 -1.049872274 -3.200249221 -2.590404984 -1.708816199 -0.937632399 -0.934865555 -0.923882555 -1.068966667 -0.898021807 -1.246155763
6.19E-01 -0.883854489 -0.954325077 -0.983489164 -3.115294118 -2.511950464 -1.644551084 -0.869783282 -0.867660709 -0.856677709 -1.002919195 -0.832182663 -1.179591331
6.15E-01 -0.817461538 -0.890538462 -0.917923077 -3.031384615 -2.434461538 -1.581076923 -0.802769231 -0.801283 -0.7903 -0.937684615 -0.767153846 -1.113846154
6.12E-01 -0.751880734 -0.82753211 -0.853159021 -2.948501529 -2.357920489 -1.518379205 -0.736574924 -0.735717251 -0.724734251 -0.873248012 -0.702920489 -1.048905199
6.08E-01 -0.687097264 -0.765291793 -0.789182371 -2.86662614 -2.28231003 -1.456443769 -0.67118541 -0.670948653 -0.659965653 -0.809594833 -0.639468085 -0.984753799
6.04E-01 -0.623096677 -0.703803625 -0.725978852 -2.785740181 -2.207613293 -1.395256798 -0.606586103 -0.606962758 -0.595979758 -0.746710876 -0.576782477 -0.921377644
I use the following code in gnuplot to check the plot
set terminal postscript eps enhanced colour font 'Times-Roman,12' size 6in,5in
set output "Plot1.eps"
set xtics out scale 1.5
set ytics out scale 1.5
set tics font ", 16"
set xlabel "10^{3}{/Symbol \264} 1/T (K^{-1})" font ",16"
set ylabel "log&{t}{/Times-Italic p}_{Pu({/Times-Italic g}),Pa} " font ",16"
set key outside right top
set key maxrows 12 spacing 2.1 font ",16" width -2
plot [0.60:0.70] 'test.dat.dat' u 1:2 with points pt 1 ps 1.75 lt rgb "red" title "Maeda {/Times-Italic et al.} [7]", \
'' u 1:3 with points pt 1 ps 1.75 lt rgb "blue" title "Pu-20Zr [7]", \
'' u 1:4 with points pt 1 ps 1.75 lt rgb "dark-green" title "Pu-50Zr [7]", \
'' u 1:5 with points pt 2 ps 1.75 lt -1 title "Present work", \
'' u 1:6 with points pt 3 ps 1.75 lt -1 title "Present work", \
'' u 1:7 with points pt 4 ps 1.75 lt rgb "red" title "Alcock [16]", \
'' u 1:8 with points pt 4 ps 1.75 lt rgb "blue" title "Phipps {/Times-Italic et al.} [19]", \
'' u 1:9 with points pt 4 ps 1.75 lt rgb "dark-green" title "Mulford [20]", \
'' u 1:10 with points pt 5 ps 1.75 lt rgb "blue" title "Kent [21]", \
'' u 1:11 with points pt 5 ps 1.75 lt rgb "red" title "Ackermann and Rauh [22]", \
'' u 1:12 with points pt 5 ps 1.75 lt rgb "dark-green" title "Bradbury and Ohse [23]", \
'' u 1:13 with points pt 5 ps 1.75 lt -1 title "Kim and Hofman [24]"
The code runs well. One can see that x axis is related to temperature as 1000/temperature. Now I wanted a linked top x2-axis with temperature in K. So, for example, xrange is from 0.6 to 0.7. Then x2 axis should be from 1000/0.6 to 1000/0.7 i.e. from 1666.67 K to 1428.57 K. So I modified the code based on linkedaxes.dem.
set terminal postscript eps enhanced colour font 'Times-Roman,12' size 6in,5in
set output "Plot2.eps"
set xtics out scale 1.5
set ytics out scale 1.5
set tics font ", 16"
set xtics nomirror
set xlabel "10^{3}{/Symbol \264} 1/T (K^{-1})" font ",16"
set ylabel "log&{t}{/Times-Italic p}_{Pu({/Times-Italic g}),Pa} " font ",16"
set key outside right top
set key maxrows 12 spacing 2.1 font ",16" width -2
set link x2 via 1000./x inverse 1000./x
set x2tics out scale 1.5
set x2label "Temperature (K)" font ",16"
plot [0.60:0.70] 'test.dat' u 1:2 with points pt 1 ps 1.75 lt rgb "red" title "Maeda {/Times-Italic et al.} [7]", \
'' u 1:3 with points pt 1 ps 1.75 lt rgb "blue" title "Pu-20Zr [7]", \
'' u 1:4 with points pt 1 ps 1.75 lt rgb "dark-green" title "Pu-50Zr [7]", \
'' u 1:5 with points pt 2 ps 1.75 lt -1 title "Present work ", \
'' u 1:6 with points pt 3 ps 1.75 lt -1 title "Present work", \
'' u 1:7 with points pt 4 ps 1.75 lt rgb "red" title "Alcock [16]", \
'' u 1:8 with points pt 4 ps 1.75 lt rgb "blue" title "Phipps {/Times-Italic et al.} [19]", \
'' u 1:9 with points pt 4 ps 1.75 lt rgb "dark-green" title "Mulford [20]", \
'' u 1:10 with points pt 5 ps 1.75 lt rgb "blue" title "Kent [21]", \
'' u 1:11 with points pt 5 ps 1.75 lt rgb "red" title "Ackermann and Rauh [22]", \
'' u 1:12 with points pt 5 ps 1.75 lt rgb "dark-green" title "Bradbury and Ohse [23]", \
'' u 1:13 with points pt 5 ps 1.75 lt -1 title "Kim and Hofman [24]"
But the set link does not give the computed values on the top x2 axis. What modifications in code need to be made?
It looks like for some reason (which I don't know) you have to give an increment for the x2tics.
Try the following minimal example:
Code:
### link x2 axis
reset session
set xrange[0.6:0.7]
set xtics nomirror
set link x2 via 1000./x inverse 1000./x
set x2tics 50
plot x
### end of code
Result:
With RedHat and Gnuplot 4.6, I've these data :
2019-08-30,384.00,225.3
2019-08-31,394.00,225.3
2019-09-01,406.00,225.3
2019-09-02,424.00,225.3
2019-09-03,439.00,225.29
2019-09-04,454.00,234.34
2019-09-05,484.00,234.34
And this script :
set title "test"
set terminal png truecolor size 960,720 background rgb "#eff1f0"
set output "/xxx/xxx/xxx/xxx/test.png"
set grid
set style line 1 \
linecolor rgb '#0060ad' \
linetype 1 linewidth 2 \
pointtype 7 pointsize 1.5
set style line 2 \
linecolor rgb "red" \
linetype 1 linewidth 1 \
pointtype 7 pointsize 1
set offsets 0.5,0.5,0,0.5
set datafile separator ","
set format y "%g"
set key left
myLabel(n) = sprintf("%g",n)
plot "df_output.txt" using 2:xtic(1) with linespoints linestyle 1 ,\
'' using 3:xtic(1) with linespoints linestyle 2 title " Free space ", \
'' using 0:2:(myLabel($2)) w labels offset 0,-0.5 notitle, \
'' using 0:3:(myLabel($3)) w labels offset 0,1 notitle, \
The result is :
I would like to put a trendline on the blue curve, So my script looks like :
set title "test"
set terminal png truecolor size 960,720 background rgb "#eff1f0"
set output "/xxx/xxx/xxx/xxx/test.png"
set grid
set style line 1 \
linecolor rgb '#0060ad' \
linetype 1 linewidth 2 \
pointtype 7 pointsize 1.5
set style line 2 \
linecolor rgb "red" \
linetype 1 linewidth 1 \
pointtype 7 pointsize 1
set offsets 0.5,0.5,0,0.5
set datafile separator ","
set format y "%g"
set key left
myLabel(n) = sprintf("%g",n)
f(x) = a*x + b
fit f(x) "df_output.txt" u 0:2 via a,b
plot "df_output.txt" using 2:xtic(1) with linespoints linestyle 1 ,\
'' using 3:xtic(1) with linespoints linestyle 2 title " Free space ", \
'' using 0:2:(myLabel($2)) w labels offset 0,-0.5 notitle, \
'' using 0:3:(myLabel($3)) w labels offset 0,1 notitle, \
f(x) w l lc "black" title "trendline"
And that works perfectly :
Without the f function and the same datas, this script works perfectly with AIX 7.2 but with the f function, I've this error in my error_log file :
Could not open log-file fit.log:
And if I try to generate manually the graph, I've this error :
Singular matrix in Invert_RtR
"gnuplot_script.txt", line 25:
The line 25 is :
fit f(x) "df_output.txt" u 0:2 via a,b
Du you have any idea about this problem ?
I am using Gnuplot to create a histogram with a plot line, however, the plot line is not fit well with bar head, also I would like to put the line a little bit far from the bar head.
set border 3
set boxwidth 0.9
set tics nomirror out scale 0.75
set style fill solid 0.8
plot "03.txt" using 2:xtic(1) lt rgb "#0060ad" notitle, "" using 2 smooth csplines notitle with lines ls 1, "" using 3 lt rgb "#ff6600" notitle, "" using 3 smooth csplines notitle with lines ls 2, "" using 4 lt rgb "#dd181f" notitle, "" using 4 smooth csplines notitle with lines ls 3
Updated:
This is the data file:
500000 25.938 25.938 2
1000000 52.385 52.385 4
1500000 79.749 78.405 6.125
2000000 152.589 100.261 12.479
2500000 224.869 118.364 19.159
This should work for any number of columns, you have to specify them in the variable N, and number them in calls to custom function xbox. This should do for a non-intensive usage. You can offset vertically the curves with the OFFSET variable (in units of y axis)
set border 3
#number of columns to be plotted
N=3
#vertical offset
OFFSET=0
#gapwidth (set to gnuplot's default)
GW=2
xbox(x,i)=x+(i-N*0.5)/(N+GW)
set boxwidth 0.9
set tics nomirror out scale 0.75
set style fill solid 0.8
plot "03.txt" using 2:xtic(1) lt rgb "0060ad" notitle, \
"" using 2 with histogram notitle, \
"" using (xbox($0,1)):($2+OFFSET) smooth csplines notitle with lines ls 1, \
"" using 3 lt rgb "#ff6600" notitle with histogram, \
"" using (xbox($0,2)):($3+OFFSET) smooth csplines notitle with lines ls 2, \
"" using 4 lt rgb "#dd181f" notitle with histogram, \
"" using (xbox($0,3)):($4+OFFSET) smooth csplines notitle with lines ls 3
Basically I have a figure below, which is drawn by gnu plot.
The code is listed as follows:
set term pdf size 2.8,1.4 font "Arial,08"
set output "plot/application.pdf"
set datafile separator ","
set offset 0, 0, 0, 0
set size ratio 0.5
set xtics norangelimit
set ytics nomirror
set termoption dashed
set ylabel "Binary Similarity (%)"
set xlabel "Iteration"
set yrange [0:110]
set style data linespoints
set key vertical maxrows 5
set key top right
set key vertical maxrows 5
set style line 2 lt 1 lc rgb "skyblue" lw 1
set style arrow 8 heads size screen 0.008,90 ls 2 lw 10
set arrow from 9.0,0 to 9.0,40 nohead lw 1 as 8
plot 'plot/application.csv' using 1:xtic((int($0)%4)==0?sprintf("%d", $0*10):"") title columnheader(1) pt 1 lw 1, \
'' using 2 title columnheader(2) pt 2 lw 1 ps .1 lc rgb "#4169E1", \
'' using 3 title columnheader(3) pt 3 lw 1 ps .1 lc rgb "#DAA520", \
'' using 4 title columnheader(4) pt 4 lw 1 ps .1 lc 5, \
'' using 5 title columnheader(5) pt 4 lw 1 ps .1 lc 9, \
'' using 6 title columnheader(6) pt 4 lw 1 ps .1 lc 7, \
'' using 7 title columnheader(7) pt 5 lw 1 ps .1 lc 8, \
'' using 7 title columnheader(8) pt 5 lw 1 ps .1 lc 9
I basically want to highlight datas at 90, and that's why I draw a blue arrow line there.. But as you can see, it looks awkward...
So I am thinking to change the blue line into a red circle, something like this:
Does anyone know how to do that? Note that it even has an associated legend of the red circle.. Thank you!
You can always add
'< echo 90 20 10' w circ
to the plot.
This is My data :
18_AGT_s 8234.00 8234.00 8234.00
18_MAC_s 8414.36 8308.36 8246.33
9_MAC_r 8414.36 8308.36 8246.33
9_MAC_s 8414.55 8309.55 8246.45
8_MAC_r 8414.55 8309.55 8246.45
8_MAC_s 8414.56 8310.08 8246.47
6_MAC_r 8414.56 8310.08 8246.47
6_MAC_s 8416.19 8310.21 8246.49
1_MAC_r 8416.19 8310.21 8246.49
and here is my gnuplot code :
plot "dat" using ($0+1):2 with linespoints pt 8 ps 2 lt 2 lw 4 lc rgb
"green" title "DMSR","dat" using ($0+1):3 with linespoints pt 5 ps 2
lt 3 lw 4 lc rgb "blue" title "Alarm","dat" using ($0+1):4 with
linespoints pt 6 ps 2 lt 4 lw 4 lc rgb "red" title "Emergency"
and here is my out put :
But In the step part I want to have 18_AGT_s and 18_MAC_s and 9_MAC_s and .... for example on the X part I want to have 18_AGT_s in stand of 1 or I want to have 18_MAC_2 instand of 2 and 9_MAC_r instand of 3 etc. Any help thanks
Use the xticlabels() option with the column number with the labels as argument (1, in this case):
# Optionally rotate labels so they fit
set xtics rotate
plot "dat" using ($0+1):2 with linespoints pt 8 ps 2 lt 2 lw 4 lc rgb \
"green" title "DMSR","dat" using ($0+1):3 with linespoints pt 5 ps 2 \
lt 3 lw 4 lc rgb "blue" title "Alarm","dat" using \
($0+1):4:xticlabels(1) with linespoints pt 6 ps 2 lt 4 lw 4 lc rgb \
"red" title "Emergency"
Here you only need to use it for the last plot instance so that it overwrites the number options.