My experimental data file is given below
### expt.dat
### User 1 User 2 User 3 User 4
### Units mg/g
10.07 9.92 9.79 9.68
10.08 9.91 9.82 9.63
10.02 9.92 9.76 9.64
10.04 9.92 9.86 9.64
10.01 9.89 9.76 9.69
10.06 9.88 9.79 9.71
Data file for plotting the boxplot is
### boxplot.dat
### Description User 1 User 2 User 3 User 4
Minimum 10.01 9.88 9.76 9.63
First Quartile-Minimum 0.015 0.015 0.0075 0.01
Medium-First Quartile 0.025 0.02 0.0225 0.02
Third Quartile-Median 0.0175 0.005 0.0225 0.0275
Max-Third Quartile 0.0125 0 0.0475 0.0225
I wish to have a two-colour boxplot in Gnuplot. But I could not modify the code in Set background of boxes in boxplot to a specific color with gnuplot
Any suggestions would be helpful.
Edit after response
Based on suggestions of @theozh, I have revised the code to suit my needs.
##
##
reset session
##
set terminal postscript eps enhanced colour font 'Times-Roman,12' size 3in,2in
set output "Boxplot_s2s3.eps"
set xtics out scale 1.5
set ytics out scale 1.5
set tics font ", 12"
set key inside top right spacing 1.55 font ",10" noautotitle
set ylabel "milligrams per gram" font ",12"
set style fill solid 0.3
set grid x,y
set style boxplot outliers pointtype 5 medianlinewidth 2.0
set for [i=1:4] xtic (sprintf("User %d",i) i)
plot for [i=1:4] 'boxplot_s1.dat' u (i):i w boxplot lc i title sprintf("User %d",i), \
For two-colour boxplot, I wish to plot u1_1 & u1_2, u2_1 & u2_2, u3_1 & u3_2 and u4_1 & u4_2
together with a different sequence of colours.
Revised data files are
# data2.dat
# User 1 User 2 User 3 User 4
19.78 19.90 19.38 19.22
19.79 19.92 19.34 19.22
19.75 19.91 19.33 19.25
19.79 19.93 19.33 19.21
19.74 19.94 19.30 19.20
19.79 19.94 19.35 19.20
# data3.dat
# User 1 User 2 User 3 User 4
39.43 38.35 37.55 37.75
39.45 38.37 37.57 37.70
39.41 38.41 37.58 37.68
39.45 38.35 37.57 37.61
39.47 38.34 37.53 37.78
39.49 38.41 37.58 37.72
If I understood your question correctly, why don't you use gnuplot's plotting style with boxplot
directly with your experimental data? gnuplot will do the math for you.
In the example below the data is in the code with in the datablock $Data
.
If you have your data in a file, skip the datablock and change the plot command, e.g plot for [i=1:4] 'expt.dat' u (i):i w boxplot ...
Depending on your preferences, you can add the users as xtic labels or as legend.
What do you mean with "two colour boxplot" if you have 4 users?
Code:
### boxplot
reset session
$Data <<EOD
### expt.dat
### User 1 User 2 User 3 User 4
### Units mg/g
10.07 9.92 9.79 9.68
10.08 9.91 9.82 9.63
10.02 9.92 9.76 9.64
10.04 9.92 9.86 9.64
10.01 9.89 9.76 9.69
10.06 9.88 9.79 9.71
EOD
set style fill solid 0.3
set key noautotitle
set grid x,y
set for [i=1:4] xtic (sprintf("User %d",i) i)
plot for [i=1:4] $Data u (i):i w boxplot lc i title sprintf("User %d",i), \
### end of code
Result: