Gnuplot Bar Chart With Error Bars
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 gnuplot boxerrorbars About Us Learn more about Stack Overflow the company Business Learn more about gnuplot error bar hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join
Gnuplot Error Bars Style
the Stack Overflow Community Stack 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 barchart histogram with
Gnuplot Boxes
errorbars up vote 7 down vote favorite 2 I want to the results of my benchmarks. I compare two virtual machines with each other and have data of the following form: BENCHMARK VM1_TIME VM1_ERROR VM2_TIME VM2_ERROR I want to generate a barchart diagram from this data which should look like this: Could somebody provide the code how to do this? I know this kind of gnuplot set style histogram request is unbeloved, but I really need this and googled for something like 2 hours, without a satisfactoring result. Thanks in advance, Sven gnuplot bar-chart share|improve this question asked Aug 19 '12 at 2:25 Sven Hager 1,14721022 1 What about sharing your data, or offering some mock data, to play with? –vaettchen Aug 19 '12 at 2:55 I do not have concrete data yet because I need to know in what format Gnuplot wants it. However, it is clear that I have 5 columns of data: 1) Benchmark name 2) Time it took VM 1 to compute it (in milliseconds) 3) Time it took VM 2 to compute it (in milliseconds) 4) Error of VM 1 times (in milliseconds) 5) Error of VM 2 times (in milliseconds) –Sven Hager Aug 19 '12 at 13:02 If you want help, you need to provide data in a way that can easily copied & pasted - dput( mydata ) is always good. It will also be a good idea to provide the code you have tried that got you close but did not work. This is not only a matter of court
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
Gnuplot Xtic
hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask gnuplot error bars and lines Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join gnuplot using them; it only takes a minute: Sign up Gnuplot Bar chart with error bars up vote 1 down vote favorite I have the following data Name Value of the bar Confidence interval A 0.62 [0.59 0.63] B 0.64 [0.54 http://stackoverflow.com/questions/12023736/gnuplot-barchart-histogram-with-errorbars 0.72] C 0.51 [0.46 0.67] D 0.33 [0.25 0.36] I tried to plot it as a bar chart with A,B,C and D labeling each bar and with and error bar. By using plot "my.dat" using 1; with boxes I only get a bar chart. Can someone help me? gnuplot bar-chart axis-labels share|improve this question asked Jul 21 '14 at 18:17 Samuel 475 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote If you http://stackoverflow.com/questions/24871941/gnuplot-bar-chart-with-error-bars also want errorbars, you must add a second plot with the yerrorbars plotting style. The brackets aren't very handy in the data file, so I remove them with a sed command: set style fill solid set boxwidth 0.8 set yrange [0:*] unset key plot "< sed 's/[][]//g' my.dat" using 0:2:xtic(1) with boxes, \ '' using 0:2:3:4 with yerrorbars lc rgb 'black' pt 1 lw 2 share|improve this answer answered Jul 21 '14 at 19:21 Christoph 29.5k72847 Thank you! That's what I wanted. –Samuel Jul 22 '14 at 8:28 Is there any possibility to change the color of the bars? So that each bar has a different color or pattern (filled with dots or lines) –Samuel Jul 22 '14 at 16:05 Yes, you can use e.g. lc variable to color the bars based on some value (possible the row number): plot "< sed 's/[][]//g' my.dat" using 0:2:0:xtic(1) lc variable with boxes. –Christoph Jul 22 '14 at 18:25 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questions tagged gnuplot bar-chart axis-labels or ask you
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 http://psy.swansea.ac.uk/staff/carter/gnuplot/gnuplot_histograms.htm 109.00 2011-04-16 98.67 30.83 202.00 2011-04-23 87.17 58.25 127.09 2011-04-30 139.74 67.33 232.84 2011-04-30 http://www.gnuplotting.org/tag/errorbars/ 20.0 10.0 30.0 Note that there 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 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 error bar be, and 2011-04-30 appears twice in the following plots. Try using 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 gnuplot error bar to read. set xtics rotate out # Select histogram data set style data histogram # Give the 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
the last entry we had mean and standard variation data for five different conditions. Now let us assume that we have only two different conditions, but have measured with three different instruments A, B and C. We have used a ANOVA to verify that the data for the two conditions are significant different. As a result the plot in Fig. 1 should be created. Fig. 1 Plot the mean and variance of the given data (code to produce this figure) Therefore we store our data in a format, that can be used by the index command in Gnuplot. Note that the data have two empty lines between the blocks in the real data file: # mean std # A 0.77671 0.20751 0.33354 0.30969 # B 0.64258 0.22984 0.19621 0.22597 # C 0.49500 0.31147 0.14567 0.21857 Now every instrument is stored in a different data block containing both conditions as columns. The color definitions and axes settings are done in a similar way as in the previous blog entry. Note that we have to define two more colors for the boxes, because we use three different colors. Also we define a black line to plot the significance indicator (arrow). set style line 1 lc rgb 'gray30' lt 1 lw 2 set style line 2 lc rgb 'gray40' lt 1 lw 2 set style line 3 lc rgb 'gray70' lt 1 lw 2 set style line 4 lc rgb 'gray90' lt 1 lw 2 set style line 5 lc rgb 'black' lt 1 lw 1.5 set style fill solid 1.0 border rgb 'grey30' The significance indicator is created by three black arrows and a text label: # Draw line for significance test set arrow 1 from 0,1 to 1,1 nohead ls 5 set arrow 2 from 0,1 to 0,0.95 nohead ls 5 set arrow 3 from 1,1 to 1,0.95 nohead ls 5 set label '**' at 0.5,1.05 center For the plot the index command is used to plot first condition A, then B and then C by using block 0,1, and 2 respectively. The x-position of the boxes for instrument A are slightly shifted to the left, the ones for C to the right by subtracting or adding the value of bs. The value of bs has the width of one box in order to plot the boxes side by side. # Size of one box bs = 0.2 # Plot mean with variance (std^2) as boxes with yerrorbar plot 'statistics.dat' i 0 u ($0-bs):1:($2**2) notitle w yerrorb ls 1, \ '' i 0 u ($0-bs):1:(bs) t 'A' w boxes ls 2, \ '' i 1 u 0:1:($2**2) notitle w yerrorb ls 1, \ '' i 1 u 0:1:(bs) t 'B' w boxes ls 3, \ '' i 2 u ($0+bs):1:($2**2) notitle w yerrorb ls 1, \ '' i 2 u ($0+bs):1:(bs) t 'C' w boxes ls 4 Tags: ANOVA, border, boxes, data, errorba