0

I have a file statistics.dat with measurements I made. It has the format

node Mean     StdDev
1    11862.4  142.871
2    11722.4  141.330 
[...]

I can make a sorted graph with plot '< sort -n -k2 statistics.dat' u 2

Now I want to add error bars to my plot. When I use plot 'statistics.dat' u 1:2:3 w errorbars The sorting is obviously lost since gnuplot uses the x- and y-value as coordinates.

Is there a way to plot a sorted graph with errorbars? Or do I need to sort my data and add new x-values according to the sorded position?

0

1 Answer 1

1

Reading the x coordinate from column 1 is counter-productive in this case. To use the ordering of the sorted file, use column 0 (line number):

  plot '< sort -n -k2 statistics.dat' u 0:2:3 w errorbars

Depending on the nature of your data and what you are trying to show in the plot, it may be better to simply use the mean value in column 2 as the x coordinate (no extra sorting required):

  plot 'statistics.dat' using 2:2:3 with errorbars

If the original file order has some intrinsic significance you might also want to encode the original order somehow, possibly as x tic labels, possibly as a color range:

  plot 'statistics.dat' using 2:2:3:1 with errorbars lc palette
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.