Search code examples
plotgnuplot

Gnuplot: plotting results from different sources in one graph


I am trying to compare the results of a measurement from different collaborations using gnuplot. The plot should ideally look like this:

Example graph

I can't figure out how to plot the different results one on top of the other, with the labels on the right. I would be really grateful if anyone could help me.


Solution

  • I show two approaches, depending of your data file. Two possible structures are data01.dat

    # data01.dat
    alpha  error
     1.0    0.2
     2.0    0.2
     1.5    0.2
    

    or data02.dat

    # data02.dat
    Collab alpha error
       1    1.0   0.2
       2    2.0   0.2
       3    1.5   0.2
    

    Using the data01-structure:

    reset
    set encoding utf8
    set terminal wxt size 480,600 font "Times New Roman,10"
    set tics out nomirror
    set xlabel "{/:Italic=12 α}"
    set link y2
    unset ytics
    set y2range [:] reverse
    set y2tics 1
    set format y2 "Collaboration %g"
    set offsets graph 0.1, 0.1, 0.5, 0.5
    
    plot "data01.dat" u 1:0:2 w xerrorbars pt 7 not
    

    Using the data02-structure almost all is the same, except the plot command.

    plot "data02.dat" u 2:1:3 w xerrorbars pt 7 not
    

    The results.

    Graph

    I hope be useful.