Quantcast

Help creating a percentage stacked bar graph

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Help creating a percentage stacked bar graph

Rafael Fontenelle
Hello there.

I'd like to create a horizontal percentage stacked bar graph from a
datfile, but learning gnuplot's syntax is kinda hard so far. My datfile
have 4 columns: first three columns provide integer values for each bar,
while the last one provides each bar's legend. Can someone please help
setting a script to generate such graph?

Thanks in advance.

Best regards,
Rafael Fontenelle
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
gnuplot-info mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help creating a percentage stacked bar graph

theozh
Horizontal bar graphs seem to be a recurrent question.
In contrast to vertical bar graphs and histograms, as far as I know
there is no direct command in gnuplot for creating horizontal ones. I do
not know why. It really would be convenient.

A somewhat cumbersome workaround does it with boxxyerrorbars.

If your file "Test.dat", e.g. looks like the following:

# Col1 Col2 Col3 Legend
5 7 12 ItemA
8 8 14 ItemB
12 24 2 ItemC
3 2 7 ItemD


Make sure that in the following code there is no newline, except after '\'.
The first plot is in absolute values, the second plot in percentage
values. The legend is written as axis tics.


#### horizontal histogram
reset
set multiplot layout 2,1

plot 'Test.dat' \
    u (0):($0):(0):($1):($0-0.4):($0+0.4):ytic(4) axes x1y1 with
boxxyerrorbars fs solid lc rgb "red" notitle,\
    '' u (0):($0):($1):($1+$2):($0-0.4):($0+0.4):ytic(4) axes x1y1 with
boxxyerrorbars fs solid lc rgb "green" notitle,\
    '' u (0):($0):($1+$2):($1+$2+$3):($0-0.4):($0+0.4):ytic(4) axes x1y1
with boxxyerrorbars fs solid lc rgb "blue" notitle,\
       

plot 'Test.dat' \
    u (0):($0):(0):(($1)/($1+$2+$3)):($0-0.4):($0+0.4):ytic(4) axes x1y1
with boxxyerrorbars fs solid lc rgb "red" notitle,\
    '' u
(0):($0):(($1)/($1+$2+$3)):(($1+$2)/($1+$2+$3)):($0-0.4):($0+0.4):ytic(4)
axes x1y1 with boxxyerrorbars fs solid lc rgb "green" notitle,\
    '' u
(0):($0):(($1+$2)/($1+$2+$3)):(($1+$2+$3)/($1+$2+$3)):($0-0.4):($0+0.4):ytic(4)
axes x1y1 with boxxyerrorbars fs solid lc rgb "blue" notitle,\
       
unset multiplot

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
gnuplot-info mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
Loading...