I have this data file (TotalDurationBarPlot.dat
):
Indexed list 934
Tree list 3692
Array list 12274
Linked list 48188
What I wish to achieve is a histogram chart with 4 bars: one for Indexed list, one for Tree list, one for Array list, one for Linked list. My requirements are:
- Each bar has it's unique color,
- On top of each bar, there is a number denoting the height of the bar. (For example, above the Tree list, there is 3692.)
- It would be nice to have a legend on a light gray background with a thin black legend border at the top right corner.
My current attempt
As of now, my data file looks like:
# ILL TL AL LL
934 3692 12274 48188
... and my gnuplot script looks like:
set title font "Monospaced,13" 'Total duration'
set grid
set key right top
set style data histograms
set style histogram cluster gap 2
set style fill solid border 2
set xtics format ""
set grid ytics
set ylabel "Milliseconds"
set yrange [0:70000]
# set boxwidth 0.5 relative
# set label "Array list\n134908 ms" at graph 0.145,0.9
ArrayListColor = "#491d75";
IndexedListColor = "#b32929";
LinkedListColor = "#d49435";
TreeListColor = "#12520b";
plot 'TotalDurationBarPlot.dat' using 1 title "Indexed list" linecolor rgb IndexedListColor, '' using 2 title "Tree list" linecolor rgb TreeListColor, '' using 3 title "Array list" linecolor rgb ArrayListColor, '' using 4 title "Linked list" linecolor rgb LinkedListColor, '' u 0:1:1 with labels offset -6.0,-100.0 title ""
set terminal png size 650,350 enhanced font "Monospaced,13"
set output 'TotalDuration.png'
replot
exit
It produces:
PS
The linked question does not address my needs here. My requirements are:
- A legend box with (RGB) color for the legend border and background,
- The thickness of the legend border,
- The color of the bars,
- The
y
-value of each bar must be typeset above the respective bar, - Minimum change in my current implementation.
(Finally, I cannot follow the code in the linked question.)