Plot histogram with specified patterns for different categories in GNUPLOT

12,460

Solution 1

It is an interesting problem. After read your question I wrote a blog to talk about it. May be you can have a look. The link is here: http://gnuplot-surprising.blogspot.com/2011/09/plot-histograms-using-boxes.html enter image description here

Solution 2

You can use with boxes fs [pattern|solid] <style-id>.

0      0.0      0.0
1      0.3      0.6
2      1.6      1.6
3      0.3      1.5
4      0.6      3.6
5      0.3      4.3
6      0.3      0.7
7      5.5      5.5
8      6.6      6.6
9      5.2      5.2
10     8.3      8.3
11     2.7      5.0
12     2.8      8.3
13     3.3      2.8
14     7.9      3.9
15     9.9      7.9
16    15.3     15.3
17    14.7     14.7
18     3.8     18.1
19    18.1     12.1

Gnuplot script:

set style data hist
set style histogram rowstacked
plot 'test.dat' us 2:xtic(1) fs solid 1 ls 3, '' us 3 fs pattern 1

enter image description here

See this link for more detail:

Share:
12,460
Summer_More_More_Tea
Author by

Summer_More_More_Tea

Updated on June 04, 2022

Comments

  • Summer_More_More_Tea
    Summer_More_More_Tea about 2 years

    I'm now gonna plot a 10-category histogram with GNUPLOT. Since number of categories is relative large, I want to specify patterns for different categories myself instead of applying the default pattern setting making different categories easy distinguished, e.g. fill the first category with dash-line while the second shaded, etc.

    Is there any parameter can be employed to specify a pattern in the plot command? Any hints/advice will be highly appreciated. Thanks in advance.

    Best Regards!

  • Summer_More_More_Tea
    Summer_More_More_Tea almost 13 years
    Thanks for the answer at first. I've tried this, unfortunately, the stacked histogram does not fulfill the requirements. :-)
  • Summer_More_More_Tea
    Summer_More_More_Tea almost 13 years
    It's a pity that blogpot is blocked in my country.:-)Thank you all the same. I'll try other approach to your post.
  • Summer_More_More_Tea
    Summer_More_More_Tea almost 13 years
    finally, I break the Wall. :-) Nice post!