Question

I have to create Graphs like this image below, I tried to use gnuplot and zplot to create this, but the patterns are not as expected. Did someone know some library or anything to create this pattern(as image bellow). I appreciate for that. Thanks

enter image description here

Was it helpful?

Solution

What you need is the following histogram type with different fill style patterns

For example if you would want a black&white stacked histogram, then you could create them by doing the following:

file1 = 'hist1.dat'

set style data histogram
set style histogram rowstack
set style fill pattern

set xtics border in scale 0,0 nomirror rotate by 90  offset character 0, -6, 0
set boxwidth 0.9 absolute

set key outside right top vertical Left
set key samplen 2.5 spacing 0.85

set ylabel "Cost BreakDown (%)" font ",18" offset character 2.5,0,0

 plot newhistogram , file1 u 2:xtic(1) t "Math" lc rgbcolor "black" lt 1 fs pattern 1, '' u 3 t "Innvocation" lc rgbcolor "black" lt 1  fs pattern 2

where the contents of file1 could be like this

Read-GetAttr 19 12 
Read-If-Mod 47 23 

The above will render the following graphic:

enter image description here

You can further add more layers on the stack by having the corresponding data and changing the fillstyle pattern fs. Further you can also change them to coloured histograms by using different rgbcolor values

Posting this here in case this may be useful for someone else in the future:

I also pulled up some work that I did previously, You can download a complete working example of coloured stacked Histograms with data files and gnuplot script from the following link:

Coloured Stacked Histograms Working Example

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top