23

I have a simple result table which I want to plot as a clustered histogram plot in gnuplot. The data set has the category of content type of a webpage and the corresponding percentage share in two columns. I have this for two browsers. For example,

For IE,
    Content      Share
    Video         30%
    Audio         10%
    Flash         25%
    HTML          20%
    Javascript    15%

   For Chrome,
    Content      Share
    Video         20%
    Audio         5%
    Flash         35%
    HTML          30%
    Javascript    10%

Now I want to plot these two data together with the Content Type in the x-axis and the corresponding share on the y-axis with legends. How do I do this?

sfactor
  • 12,592
  • 32
  • 102
  • 152
  • 2
    Did you try this already? http://www.codealias.info/technotes/gnuplot_cluster_histogram_example (3rd google response to your question) What problem did you have? – Tom Feb 27 '11 at 02:01

1 Answers1

42

If you turn your data into a table, this becomes relatively easy.

info.dat should contain:

Broswer Video   Audio   Flash   HTML    JavaScript
IE      30%     10%     25%     20%     15%
Chrome  20%     5%      35%     30%     10%

Then use something like:

set terminal pdf enhanced
set output 'bar.pdf'

set style data histogram
set style histogram cluster gap 1

set style fill solid border rgb "black"
set auto x
set yrange [0:*]
plot 'info.dat' using 2:xtic(1) title col, \
        '' using 3:xtic(1) title col, \
        '' using 4:xtic(1) title col, \
        '' using 5:xtic(1) title col, \
        '' using 6:xtic(1) title col

To create your plot. Here's one I made earlier: Clustered bar graph

Brad
  • 5,845
  • 7
  • 30
  • 29
Matt
  • 5,522
  • 5
  • 29
  • 24