How can I plot a comparison graph of two values from the file (first row - titles, second row - values, third row - uncertainties):
value1 value2
6,7147 6,7131
0,0036 0,0102
To get this graph:
Under linux (bash script), using gnuplot.
Your data format is a bit unfortunate. In this case it would be better if the data was transposed. Unfortunately, gnuplot doesn't have a built-in transpose function. So, if you can't transpose your data with some other tools, the gnuplot commands for plotting this data will get a bit cumbersome. Maybe there is an easier solution which I am currently not aware of.
Next thing is that you have comma as decimal separator in the input format. Standard in gnuplot is decimalpoint (check help decimalsign
).
You can change it by set decimalsign locale "<...>"
, e.g. french
or german
or maybe others should work, depending on what you have installed. Check the following code example.
Code:
### yerrorbar with row data
reset session
# data format easy for gnuplot
$Data1 <<EOD
value1 6,7147 0,0036
value2 6,7131 0,0102
EOD
# data format difficult for gnuplot
$Data2 <<EOD
value1 value2
6,7147 6,7131
0,0036 0,0102
EOD
unset key
set decimalsign locale "french" # or "german" should also work
set xrange [0.5:2.5]
plot $Data1 u ($0+1):2:3:xtic(1) w yerrorbar pt 5 lc "red" notitle
pause -1 # wait until OK pressed
plot for [i=1:2] y2=y1=NaN $Data2 u (i):(y0=y1,y1=y2,y2=column(i),y1):(y2):xtic(columnhead(i)) w yerrorbar pt 5 lc "blue"
### end of code
Result: