Skip to content

[GNUPLOT] Histogram rowstacked (2)

by on 29 December 2011

Bagaimana jika nilai Y pada grafik di halaman ini dirubah menjadi presentase kontribusi?

Berikut ini grafiknya:

Datanya sama dengan data pada halaman sebelumnya (data demo1.dat):

Dengan menggunakan data yang sama pada halaman ini, berikut ini script-nya:

#!/bin/bash
dir=/home/dir/Documents/project/GNUPLOTdemo
gnuplot <<EOF
 #HISTOGRAM ROWSTACKED
 set term postscript enhanced color
 set output "$dir/demo1.ps"
 set datafile missing "NaN"
 set style data histogram
 set style histogram rowstacked
 set style fill pattern border 1
 set boxwidth 0.75
 set ylabel "% of total contribution" font "Arial,18"
 set xlabel "Category" font "Arial,18"
 set xtics nomirror norotate
 set yrange [0:100]
 set key outside right top vertical Left enhanced autotitles columnhead nobox
 set key samplen 3 spacing 1 width 0 height 0
 set xtics ("K" 0, "L" 1, "M" 2, "N" 3, "O" 4)
 #
 plot "demo1.dat" using (100.*(\$2)/(\$13)) title column(2) fs pattern 1, \
 '' using (100.*(\$3)/(\$13)) title column(3) fs pattern 2, \
 '' using (100.*(\$4)/(\$13)) title column(4) fs pattern 4, \
 '' using (100.*(\$5)/(\$13)) title column(5) fs pattern 22, \
 '' using (100.*(\$6)/(\$13)) title column(6) fs pattern 5, \
 '' using (100.*(\$7)/(\$13)) title column(7) fs pattern 6, \
 '' using (100.*(\$8)/(\$13)) title column(8) fs pattern 7, \
 '' using (100.*(\$9)/(\$13)) title column(9) fs pattern 8, \
 '' using (100.*(\$10)/(\$13)) title column(10) fs pattern 9, \
 '' using (100.*(\$11)/(\$13)) title column(11) fs pattern 10, \
 '' using (100.*(\$12)/(\$13)) title column(12) fs pattern 60
 EOF

From → GNUPLOT

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.