logo
down
shadow

Histogram and any curve on the same plot in Gnuplot


Histogram and any curve on the same plot in Gnuplot

By : ChrisBTC
Date : November 22 2020, 01:01 AM
around this issue Not having the data set you are plotting, I must guess how the final result should look like...
When plotting histograms, gnuplot implicitely places the boxes at integer x-values, starting at 0, and with custom xtics, when having using 2:xtic(1). You set the xrange to [1:1.43] to plot your function properly. Probably you want to plot with boxes to get it right.
code :
f(x)=99*0.03*(1/(0.062*sqrt(2*pi)))*exp(-((x-1.28)**2)/(2*(0.062**2)))    
set xrange [1:1.43]   
set yrange [0:25]   

set boxwidth 0.8 relative   
set style fill solid 1.00 border lt -1   
set datafile missing '-'   

plot f(x), 'histogram1.txt' using 1:2 with boxes


Share : facebook icon twitter icon
How can I add specified color to 2-d curve in 3-d plot in Gnuplot?

How can I add specified color to 2-d curve in 3-d plot in Gnuplot?


By : Laurent Herledan
Date : March 29 2020, 07:55 AM
this will help I had a working code as follows: , You need to use the linecolor command
code :
plot 0.1*sin(25*t)-1,0.1*cos(25*t)-0.5 lw 1 lc rgb "green"
Polishing gnuplot histogram plot

Polishing gnuplot histogram plot


By : Timi Adesoji
Date : March 29 2020, 07:55 AM
hop of those help? I am trying to plot some execution times of certain datasets 1, 2 and 3 using from 1 up to 12 threads. Based on hints from other collaborators, I've managed to plot something, but is still raw and needs a few modifications. , I believe that this will accomplish what you want:
code :
set xlabel "Number of threads"
set ylabel "Execution time"

set style fill solid 1.0 noborder

set boxwidth 0.7

set xtics ("1" 19.5)
set for[i=2:12] xtics add (sprintf("%d",i) (i-1)*55+19.5) 

set key top right

set xrange[-15:660]

plot for [i=0:2] for [j=0:9] 'test.dat' using ($0*55+j+i*15):1 every 30::(i*10+j) with boxes lt (i+1) t (j==0)?sprintf("Data Set %d",i+1):""
tcommand = "("
do for[i=1:12] {tcommand = sprintf("%s \"%d\" %f,",tcommand,i,(i-1)*55+19.5)}
tcommand = tcommand[1:strlen(tcommand)-1].")"
set xtics @tcommand
( "1" 19.500000, "2" 74.500000, "3" 129.500000, "4" 184.500000, "5" 239.500000, "6" 294.500000, "7" 349.500000, "8" 404.500000, "9" 459.500000, "10" 514.500000, "11" 569.500000, "12" 624.500000)
               Data set 1
     1 thread   2 threads   3 threads ...
1st  0          30          60
2nd  1          31          61
...

               Data set 2
     1 thread   2 threads   3 threads ...
1st  10         40          70
2nd  11         41          71
...
plot for [i=0:2] 'test.dat' u (i*15 + floor($0/10)*55 + int($0)%10):1 every ::(i*120)::((i+1)*120-1) w boxes t sprintf("Data set %d",i+1)
Gnuplot histogram with plot line

Gnuplot histogram with plot line


By : eurobax
Date : March 29 2020, 07:55 AM
hop of those help? 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)
code :
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
Gnuplot histogram plot style

Gnuplot histogram plot style


By : naz
Date : March 29 2020, 07:55 AM
may help you . According to the gnuplot demo page (http://gnuplot.sourceforge.net/demo/histograms.html) clustered histograms should be plotted like this:
code :
plot "Data.out" u 2:xtic(1), '' u 6, '' u 10, '' u 14, '' u 18
### clustered histograms realized "manually" with boxes
reset session
unset title
unset key

$Data <<EOD
PS        105  169 169 169   68  0 0 255    105 169 169 169    0  169 169 169    0   169 169 169    0  169 169 169 
GMQ       43    0  255  0    39  0 0 255    40   34 139  34   105 169 169 169    105 169 169 169    0  169 169 169
GL        81    0  255  0    40  0 0 255    105 169 169 169    0  169 169 169    0   169 169 169    0  169 169 169   
CM_{1}    105  169 169 169   47  0 0 255    105 169 169 169    32 169 169 169    105 169 169 169    0  169 169 169
CM_{2}    105  169 169 169   44  0 0 255    105 169 169 169   105 169 169 169    105 169 169 169    0  169 169 169
P         105  169 169 169   105 0 0 255    105 169 169 169    0  169 169 169    0   169 169 169    0  169 169 169
MH        105  169 169 169   69  0 0 255    105 169 169 169    0  169 169 169    0   169 169 169    0  169 169 169
EOD

set ylabel "Training Set size [-]"
set yrange [0.0:150.]
set grid ytics lw 2 
set style fill solid 
set boxwidth 1.0
rgb(r,g,b) = int(r)*65536 + int(g)*256 + int(b)

ColSequence = "2 6 10 14 18"
myBoxWidth = 0.8
Gap = 2
ColCount = int(words(ColSequence))
ColNo(n) = int(word(ColSequence,n))
Color(n) = rgb(column(n+1),column(n+2),column(n+3))
BoxOffset(n) = 1./(ColCount+Gap)*n - 0.5
plot for [i=1:ColCount] $Data u ($0+BoxOffset(i)):(column(ColNo(i))): \
    (1./(ColCount+Gap)*myBoxWidth):(Color(ColNo(i))) w boxes lc rgb var, \
     $Data u 0:(0):xtic(1) w boxes
### end of code
How to plot histogram using gnuplot

How to plot histogram using gnuplot


By : phynars
Date : March 29 2020, 07:55 AM
This might help you Edit #1
Based on both this and this answers, your could try:
code :
binwidth = 100
bin(x, width) = width*floor(x/width)

set tics out nomirror
set style fill transparent solid 0.5 border lt -1
set xrange [0:1000]
set xtics binwidth
set boxwidth binwidth
set yrange [0:3]

$data <<EOD
250 wire_0
350 wire_1
360 wire_2
800 wire_3
EOD

plot $data u (bin($1,binwidth)):(1.0) smooth freq with boxes notitle
set table $data2
    plot $data u (bin($1,binwidth)):(1.0) smooth freq with boxes;
unset table

plot $data2 u 1:2 w boxes notitle , "" u 1:2:2 w labels offset 0,1 notitle
Related Posts Related Posts :
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org