Adding even more bars is a simple as simply adding another plot. "" using 3 title "From web" lt rgb "#40FF00" Plot "registrations.dat" using 2:xtic(1) title "Total" lt rgb "#406090",\ In charts with multiple columns of data it would be smart to add the legend that we removed in the previous post. The bars slightly overlap, which we can fix by changing the box width to a slightly smaller value: set boxwidth 0.8 set terminal jpeg giant font 'Helvetica' 16 set output plot.jpg set key left set grid y set style data histograms set style histogram rowstacked set boxwidth 0.5 set style fill solid 1.0 border -1 set ytics 10 nomirror set yrange :60 set ylabel 'Number of.
Let’s add a second plot: set style data histograms The following Gnuplot code snippet generates a stacked histogram plot, as shown below. Now we’re all set to start plotting multiple bars. This looks a lot like the final result from the previous post. We then set the plotting style to “histograms”. We change the boxwidth to “1” (from 0.6 in in the previous post). Plot "registrations.dat" using 2:xtic(1) lt rgb "#406090" Let’s first see how that works with a single bar: set boxwidth 1 The plotting method we use can’t deal with that. While that could be a useful way to represent your data, what if you want the bars to appear next to each other? Now we run into a problem. If we add the “with boxes” option to the second plotting rule, we’ll see that it creates overlapping bars: plot "registrations.dat" using 2:xticlabels(1) with boxes lt rgb "#406090",\ This is what it produces:Īs you can see, it plots the third column of data as “X”s on top of the current bar. We define the third column and set a different color for the second set of data. To plot a second set of data, we just add another plotting rule after the first one: plot "registrations.dat" using 2:xticlabels(1) with boxes lt rgb "#406090" ,\ In the previous post, we used the “plot … with boxes” method of plotting bar charts.
We will re-use the Gnuplot settings from the previous post. Such charts take multiple columns of data and plot them grouped in the chart.
In this post I want to show you how to plot bar charts with multiple bars. Those were simple bar charts with a single bar. In my previous post I showed how to generate good looking charts with Gnuplot.