Histogram Error Bar Gnuplot
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack gnuplot boxerrorbars Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack
Gnuplot Error Bar
Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Gnuplot histogram with set bars gnuplot errorbars (High and Low) up vote 0 down vote favorite I am trying to create a histogram (barchart) with High and Low errors, using gnuplot. I have found this thread Gnuplot barchart histogram with errorbars Unfortunately it consists only from X value gnuplot error bars style and X-error (2 vaues). Whats I would like to achieve is X value (average) and error bar consisting of High and Low values (total 3: avg, High and Low). How I can do this using gnuplot? My script is identical to the one mentioned in the Thread, I only changed some labels etc (simple cosmetic changes). My example dataset structure is as follows: WikiVote 10 12 7 gnuplot histogram bar-chart share|improve this question asked Mar 12 '13 at 20:30 alien01 5721923 How is that
Gnuplot Bar Chart
not what you have? It seems to me that the bar is the average and then you have the errorbar for high and low ranges. What am I missing here? Please elaborate. –mgilson Mar 12 '13 at 23:59 The error bar high and low are same distance from Y. As far as I can tell my script takes col2 as avg and then creates both high and low errors based on col3 as a distance from avg. I would like it to use col2 as avg, col3 as high and col4 as low. –alien01 Mar 13 '13 at 0:09 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote accepted If you have a very simple datafile: #y ymin ymax 4 3 8 You can plot this datafile using: set yrange [0:] set style histogram errorbars gap 2 lw 1 plot 'datafile' u 1:2:3 w hist share|improve this answer answered Mar 13 '13 at 0:47 mgilson 153k23250364 add a comment| up vote 0 down vote I have modified the code provided by mgilson, to achieve multiple histograms for a single X value. If anybody needs it here is the code. plot 'stack_2.dat' u 2:3:4:xtic(1) w hist ti "Hadoop" linecolor rgb "#FF0000", '' u 5:6:7:xtic(1) w hist ti "Giraph" lt 1 lc rgb "#00FF00" Here is the pattern #y_0 #min #max #y_1 #min #max Dataset 4 3 8 6 5 9 share|improve this answer answered Mar 13 '13 at 10:40 alien01 5721923 add a comment| Your Answer draft saved dra
30.34 22.58 161.08 2011-01-15 23.83 20.33 104.00 2011-01-22 50.50 16.17 79.75 2011-01-29 67.59 21.74 99.25 2011-02-05 37.58 33.33 155.33 2011-02-12 48.17 44.33 66.00 2011-02-19 89.34 12.42 91.42 2011-02-26 113.09 35.83 123.34 2011-04-02 174.25 105.25 221.25 2011-04-09 98.09 55.92 109.00 2011-04-16 98.67 30.83 202.00 gnuplot boxes 2011-04-23 87.17 58.25 127.09 2011-04-30 139.74 67.33 232.84 2011-04-30 20.0 10.0 30.0 Note that there histogram gnuplot are two entries (the last two lines) for 2011-04-30; this is intentional (to demonstrate a point about time-based x values). As described in
Gnuplot Error Bars Standard Deviation
my page on time-based histograms, gnuplot does not support date/time values (as opposed to labels) for the x axis. Hence, there is no gap where March should be, and 2011-04-30 appears twice in the following plots. Try using http://stackoverflow.com/questions/15371500/gnuplot-histogram-with-errorbars-high-and-low set xdata time and you'll see what I mean; you'll get the error message "need full using spec for x time data". Similarly, set timefmt and set xdata time will have no effect. The following plot commands are common to all four of the histograms shown in this page. clear reset unset key # Make the x axis labels easier to read. set xtics rotate out # Select histogram data set style data histogram # Give the http://psy.swansea.ac.uk/staff/carter/gnuplot/gnuplot_histograms.htm bars a plain fill pattern, and draw a solid line around them. set style fill solid border Clustered With the clustered style, one column in the data file corresponds to one bar in the plot, whilst the lines of the data file correspond to the clusters of the bars. Thus, using the following plot commands, we get three bars in each cluster, and one cluster for each row (notice the two clusters for 2011-04-30, which is what we expect). set style histogram clustered plot for [COL=2:4] 'date_mins.tsv' using COL:xticlabels(1) title columnheader Figure 1: Clustered Histogram Note the use of the for feature. This allows us to select multiple columns (2 to 4, in this case); without the for, we'd only be able to plot one column of data (using something like plot 'date_mins.tsv' using 3:xticlabels(1)), which defeats the purpose of the clustered histogram: Errorbars The next histogram type is errorbars. For this, gnuplot can accept up to three columns for y values: the main value for the height of the bar, and a minimum and maximum value for the errorbar. Thus: # We need to set lw in order for error bars to actually appear. set style histogram errorbars linewidth 1 # Make the bars semi-transparent so that the errorbars are easier to see. set style fill solid 0.3 set bars front plot 'date_mins.tsv' using 2:3:4:xticlabels(1) title
by the various errorbar styles. In the default situation, gnuplot expects to see three, four, or six numbers on each line http://gnuplot.sourceforge.net/docs_4.2/node140.html of the data file -- either (x, y, ydelta), (x, y, ylow, yhigh), (x, y, xdelta), (x, y, xlow, xhigh), (x, y, xdelta, ydelta), or (x, y, xlow, http://web.mit.edu/gnuplot_v4.2/doc/htmldocs/node249.html xhigh, ylow, yhigh). The x coordinate must be specified. The order of the numbers must be exactly as given above, though the using qualifier can manipulate the order and error bar provide values for missing columns. For example, plot 'file' with errorbars plot 'file' using 1:2:(sqrt($1)) with xerrorbars plot 'file' using 1:2:($1-$3):($1+$3):4:5 with xyerrorbars The last example is for a file containing an unsupported combination of relative x and absolute y errors. The using entry generates absolute x min and max from the relative error. The y error bar gnuplot error bar is a vertical line plotted from (x, ylow) to (x, yhigh). If ydelta is specified instead of ylow and yhigh, ylow = y - ydelta and yhigh = y + ydelta are derived. If there are only two numbers on the record, yhigh and ylow are both set to y. The x error bar is a horizontal line computed in the same fashion. To get lines plotted between the data points, plot the data file twice, once with errorbars and once with lines (but remember to use the notitle option on one to avoid two entries in the key). Alternately, use the errorlines command (see errorlines (p.)). The error bars have crossbars at each end unless set bars is used (see set bars (p.) for details). If autoscaling is on, the ranges will be adjusted to include the error bars. See also http://gnuplot.sourceforge.net/demo/mgr.htmlerrorbar demos. See plot using (p.), plot with (p.), and set style (p.) for more information. Next: Errorlines Up: Plot Previous: Zticlabels Contents Index Ethan Merritt 2007-03-03
command must specify a single input data source (e.g. one column of the input file), possibly with associated tic values or key titles. Four styles of histogram layout are currently supported. set style histogram clustered {gap