Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plot error_bars with lines in gnuplot

Tags:

gnuplot

I have a file with the delivery rate of a simulation and its confidence interval. I need to plot an error bar on my chart. Need to be the line graph and also the error bar on a single chart

Sample data:

V   D         IC
10 99.2373 0.000200729
30 97.2515 0.00649952
60 94.6761 0.00950475

I would like it to look like the example below:

Example

Here is my code:

set nokey
set grid
set key right inside
set xlabel 'Velocidade em Km/h'
set ylabel 'Taxa de Entrega'
set autoscale
set yr[0:100]
set style data lines
plot 'taxa_entrega-AODV-50-250.txt' using 1:2:($2-$3):($2+$3) with yerrorbars
like image 726
Danilo Renato De Assis Avatar asked Oct 17 '25 19:10

Danilo Renato De Assis


2 Answers

if you are plotting errorbars you typically plot data with points but not necessarily with connected lines or linespoints. Instead you add a line described by a model or fit. However, from the image you are referring to I assume you want to have the points nevertheless connected. So, simply add ,\ the same data '' again as lines.

plot 'taxa_entrega-AODV-50-250.txt' using 1:2:($2-$3):($2+$3) with yerrorbars,\
    '' using 1:2 with lines

Addition: See below what you get with the full code. (I commented out the set yrange[0:100] because otherwise one wouldn't see too much with the data you provided. Furthermore, your errobars are in the range of 0.0002 to 0.009. Relative to the values 94.6 to 99.2, these will not be bars but more points.

reset session
set nokey 
set grid 
set key right inside 
set xlabel 'Velocidade em Km/h' 
set ylabel 'Taxa de Entrega' 
set autoscale 
# set yrange[0:100] 
set style data lines 

plot 'taxa_entrega-AODV-50-250.txt' using 1:2:($2-$3):($2+$3) with yerrorbars,\
    '' using 1:2 with lines

enter image description here

like image 116
theozh Avatar answered Oct 22 '25 08:10

theozh


This is a bit late, yet I hope someone finds this useful. Gnuplot actually has something already built-in which is errorlines. It connects the center points with a line as asked for.

When using errorbars the connected lines are simply omitted. Thus errorbars is the counterpart if you want a points style, and errorlines for the linespoints style.

like image 39
Simon T. Avatar answered Oct 22 '25 08:10

Simon T.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!