Add gnuplot horizontal line histogram

I would like to add a horizontal line in my histogram in gnuplot, is this possible?

My histogram has on the x axis: alea1 alea 2 alea3 nalea1 nalea 2 nalea 3 and the y axis goes from 0 to 25.

At 22, I want to add a horizontal line that runs all the way from one end to the other end of the histogram.

+8
gnuplot histogram
source share
2 answers

Try to add

, 22 title "" 

at the end of your plot command. Works for my test data (file "histo"):

 # Year Red Green Blue 1990 33 45 18 1991 35 42 19 1992 34 44 14 1993 37 43 25 1994 47 15 30 1995 41 14 32 1996 42 20 35 1997 39 21 31 plot "histo" u 2 t "Red" w histograms, "" u 3 t "Green" w histograms, "" u 4 t "Blue" w histograms, 22 title "" 

(taken from Philip C. Hunter, Gnuplot in action)

+10
source share

A typical way to add horizontal and / or vertical lines is arrow

 set arrow from x1,y1 to x2,y2 nohead linestyle ... 

For the horizontal line, y1 and y2 will be the same. From your question, I'm a little unsure what you mean by "at 22", but I assume that you want you to plot the y=22 line y=22 top of the histogram. If this happens, try this (before your plot command).

 set arrow from graph 0,first 22 to graph 1,first 22 nohead lc rgb "#000000" front 
+7
source share

All Articles